1000* 1000의 탐색은 쉽게 시간초과가 된다는 것을 충분히 인지해야 한다. 그래서 어려웠다. 1000* 1000 사이즈의 노드에서 하나씩 BFS하는 것은 (1000 * 1000) 에 대해 (1000*1000) 을 수행하는 것과 같다. 즉, 시간초과다. https://www.acmicpc.net/problem/16946 #맞는 풀이 #include #include #include #include #include #define X first #define Y second #define SIZE 1000 using namespace std; int dx[4] = { -1,1,0,0 }; int dy[4] = { 0,0,-1,1 }; int r, c; //행, 열 char given[SIZE][SIZE];..