老哥,你的判断错了。
by OceanLiu @ 2020-01-19 11:36:09
建议使用dfs
```cpp
void dfs(int x,int y)
{
if (x<0||x>n+1||y<0||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]);
}
```
by OceanLiu @ 2020-01-19 11:37:19
只有一个0被四个1围着时,0才能变成2;
你的代码把所有的0都变成2了
by OceanLiu @ 2020-01-19 11:38:14
@[DarthVictor](/user/239287) ~~抄题解是不好的行为哦~~
by wwsz_cn @ 2020-01-19 11:55:55
@[OceanLiu](/user/235013) ?
by DarthVictor @ 2020-01-19 12:00:20
@[OceanLiu](/user/235013) 输出是对的
by DarthVictor @ 2020-01-19 12:01:21