奇异错误求助

P1162 填涂颜色

你是超时了还是wa掉了?
by _Glassy_Sky_ @ 2023-01-09 21:27:55


@[Midnight_szx](/user/801371)
by _Glassy_Sky_ @ 2023-01-09 21:28:11


@[FZwangmuem](/user/677581) wa
by Midnight_szx @ 2023-01-09 21:32:55


我的代码是这样的,我在写题,你对一下 ```cpp #include<bits/stdc++.h> using namespace std; const int maxn = 1e3 + 10; int a[maxn][maxn]; int dx[5] = {0, 0, 1, -1}; int dy[5] = {1, -1, 0, 0}; int n; void dfs(int x, int y) { if(a[x][y] == 0) { a[x][y] = 3; for(int i = 0; i < 4; i ++) { int nx = x + dx[i], ny = y + dy[i]; if(nx > 0 && nx <= n && ny > 0 && ny <= n) dfs(nx, ny); } } } int main() { cin >> n; for(int i = 1; i <= n; i ++) for(int j = 1; j <= n; j ++) cin >> a[i][j]; for(int i = 1; i <= n; i ++) { dfs(i, 1); dfs(i, n); dfs(1, i); dfs(n, i); } for(int i = 1; i <= n; i ++) { for(int j = 1; j <= n; j ++) { if(a[i][j] == 3) cout << "0 "; if(a[i][j] == 0) cout << "2 "; if(a[i][j] == 1) cout << "1 "; } cout << endl; } return 0; } ```
by _Glassy_Sky_ @ 2023-01-09 21:35:30


也是BFS
by _Glassy_Sky_ @ 2023-01-09 21:35:51


@[FZwangmuem](/user/677581) 《BFS》emm...
by Midnight_szx @ 2023-01-09 21:36:42


您是wa了#4对吧 输入: ``` 20 0 0 0 0 1 1 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 1 1 1 1 1 0 1 1 1 1 1 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0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0 0 0 0 0 0 0 0 0 0 1 2 1 2 2 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 2 2 1 1 1 0 0 0 0 ```
by MinCat @ 2023-01-09 21:36:46


这个很容易看出来吧
by MinCat @ 2023-01-09 21:37:20


@[Midnight_szx](/user/801371) 写错了。。。
by _Glassy_Sky_ @ 2023-01-09 21:37:53


@[OIer_zhez](/user/871641) 看当然是看得出来
by Midnight_szx @ 2023-01-09 21:38:10


| 下一页