#define _CRT_SECURE_NO_WARNINGS #include #include #include using namespace std; int check[101][101]; //방문여부와 거리 합산하여 저장한다. int grid[101][101]; int dx[4] = {-1,0,0,1 }; int dy[4] = { 0,-1,1,0 }; int n, m; int bfs(int x, int y){ queue q; check[1][1] = 1; q.push(make_pair(x, y)); while (!q.empty()) { x = q.front().first; y = q.front().second; q.pop(); for (int i = 0; i < 4; i++) { int nx = x + dx[i..