我觉得我WA了的那个输出跟正确out一样啊 WA第五个点
#include <bits/stdc++.h>
#define LL long long
#define DB double
#define BUG cout << "OoO" << endl
using namespace std;
const int N = 31;
int n;
int A[N][N];
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
void DFS(int x, int y)
{
for(int i = 0; i < 4; i ++ )
{
int xx = x + dx[i];
int yy = y + dy[i];
if(xx < 1 || xx > n || yy < 1 || yy > n) continue;
if(A[xx][yy] != 0) continue;
A[xx][yy] = 3;
DFS(xx, yy);
}
}
int main()
{
scanf("%d", &n);
for(int i = 2; i <= n + 1; i ++ )
{
for(int j = 2; j <= n + 1; j ++ )
cin >> A[i][j];
}
n += 2;
DFS(1, 1);
for(int i = 2; i < n; i ++ )
{
for(int j = 2; j < n; j ++ )
{
if(A[i][j] == 1) printf("1 ");
else
{
A[i][j] = A[i][j] == 3 ? 0 : 2;
printf("%d ", A[i][j]);
}
}
puts("");
}
return 0;
}