#define _CRT_SECURE_NO_WARNINGS #include #include #include using namespace std; bool check[51][51]; int grid[51][51]; int dx[8] = { -1,0,1,-1,1,-1,0,1 }; int dy[8] = { -1,-1,-1,0,0,1,1,1 }; int n, m; void dfs(int x, int y) { check[x][y] = true; for (int i = 0; i = 1 && nx = 1 && ny > m >> n; if (n == 0 && m == 0) break; for (int i = 1; i