```cpp
#include<bits/stdc++.h>
using namespace std;
int a[32][32];
int dx[5]={0,-1,1,0,0};
int dy[5]={0,0,0,-1,1};
int n,i;
void dfs(int x,int y){
if(x<0||y<0||x>n+1||y>n+1||a[x][y]!=0)
return;
a[x][y]=2;
for(int i=1;i<=4;i++)
dfs(x+dx[i],y+dy[i]);
}
int main()
{
int n;
scanf("%d",&n);
for(int i1=1;i1<=n;i1++)
for(int j1=1;j1<=n;j1++)
scanf("%d",&a[i1][j1]);
cout<<endl;
dfs(0,0);
for(int i1=1;i1<=n;i1++)
{
for (int j1=1;j1<=n;j1++)
cout<<a[i1][j1]<<' ';
cout<<'\n';
}
return 0;
}
```
by 知光 @ 2019-02-26 13:32:27
为什么怎么了
by 已注销%Jm9VScx @ 2019-02-26 13:34:13
为什么怎么了
by 已注销%Jm9VScx @ 2019-02-26 13:34:23
外面怎么没有被改为2;
by 知光 @ 2019-02-26 13:34:52
@[L_T_F_](/space/show?uid=125665)
染色染不到外面啊。
by 知光 @ 2019-02-26 13:36:57