我看看
by xhQYm @ 2020-06-03 13:34:40
@[SIXIANG](/user/298549) 改成这样:
```cpp
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int map[1000][1000];
int cais[1000][1000];
int dx[5]={0,-1,1,0,0};
int dy[5]={0,0,0,-1,1};
int n;
void dfs(int x,int y)
{
if(x>n+1||x<0||y>n+1||y<0||map[x][y]!=0)return ;
map[x][y]=1;
for(int p=1;p<=4;p++)
dfs(x+dx[p],y+dy[p]);
}
int main()
{
cin>>n;
for(int p=1;p<=n;p++)
for(int i=1;i<=n;i++)
{
cin>>cais[p][i];
if(cais[p][i]==0)
map[p][i]=0;
else
map[p][i]=2;
}
dfs(0,0);
for(int p=1;p<=n;p++)
{
for(int i=1;i<=n;i++)
if(map[p][i]==0)cout<<2<<' ';
else cout<<cais[p][i]<<' ';
cout<<endl;
}
return 0;
}
```
by xhQYm @ 2020-06-03 13:37:40
@[SIXIANG](/user/298549) 第一篇题解的思路是在外面加上一圈“0”,所以边界判断有问题
by xhQYm @ 2020-06-03 13:38:30