https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AXmwOSJaSNIDFARX
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
char map[50][50];
int flag = 0;
void check(int y, int x) {
int direct[4][2] = {
0,0,
0,1,
1,0,
1,1
};
for (int i = 0; i < 4; i++) {
if (map[y + direct[i][0]][x + direct[i][1]] != '#') {
flag = 1;
return;
}
map[y + direct[i][0]][x + direct[i][1]] = '.';
}
}
int main() {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
int n, m;
for (int y = 0; y < 50; y++) {
for (int x = 0; x < 50; x++) {
map[y][x] = '\0';
}
}
cin >> n >> m;
flag = 0;
for (int y = 0; y < n; y++) {
for (int x = 0; x < m; x++) {
cin >> map[y][x];
}
}
for (int y = 0; y < n; y++) {
for (int x = 0; x < m; x++) {
if (map[y][x] == '#') {
check(y, x);
}
if (flag == 1) break;
}
if (flag == 1) break;
}
cout << "#" << i + 1 << " ";
if (flag == 1) cout << "NO" << endl;
else cout << "YES" << endl;
}
return 0;
}
'APS > SWEA' 카테고리의 다른 글
1216. [S/W 문제해결 기본] 3일차 - 회문2 (0) | 2021.11.19 |
---|---|
1860. 진기의 최고급 붕어빵 (0) | 2021.11.09 |
2805. 농작물 수확하기 c++ (0) | 2021.11.07 |
1859. 백만 장자 프로젝트 C++ (0) | 2021.11.07 |
1220. [S/W 문제해결 기본] 5일차 - Magnetic C++ (0) | 2021.08.30 |