# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
762996 | 2023-06-22T02:14:30 Z | boyliguanhan | Cop and Robber (BOI14_coprobber) | C++17 | 165 ms | 8724 KB |
#include "coprobber.h" #pragma GCC optimize(2) int ok[MAX_N][MAX_N][2], move[MAX_N][MAX_N], vis[MAX_N][MAX_N][2], inp[MAX_N][MAX_N][2], n; bool a[MAX_N][MAX_N]; int pos; bool dfs(int c, int r, int t) { if(c==r) return ok[c][r][t]=1; if(inp[c][r][t]) return 0; if(vis[c][r][t]) return ok[c][r][t]; inp[c][r][t] = 1; if(t) { ok[c][r][t] = 1; for(int i = 0; i < n; i++) if(a[r][i]&&!dfs(c,i,0)) return vis[c][r][t]=1,inp[c][r][t]=ok[c][r][t]=0; return inp[c][r][t]=0,vis[c][r][t]=1; } if(dfs(c,r,1)) return move[c][r] = c,inp[c][r][t]=0,vis[c][r][t]=ok[c][r][t]=1; for(int i = 0; i < n; i++) if(a[c][i]&&dfs(i,r,1)) return move[c][r]=i,inp[c][r][t]=0,vis[c][r][t]=ok[c][r][t]=1; return move[c][r]=-1,vis[c][r][t]=1,inp[c][r][t]=0; } int start(int N, bool A[MAX_N][MAX_N]) { n = N; for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) a[i][j] = A[i][j]; for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) dfs(i,j,0); for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(move[i][j]==-1) break; if(j==n-1) return pos = i; } } return -1; } int nextMove(int R) { return pos=move[pos][R]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 336 KB | Output is correct |
2 | Correct | 0 ms | 336 KB | Output is correct |
3 | Correct | 0 ms | 336 KB | Output is correct |
4 | Incorrect | 165 ms | 8724 KB | Cop can catch the robber, but start() returned -1 |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 336 KB | Output is correct |
2 | Incorrect | 0 ms | 464 KB | Cop can catch the robber, but start() returned -1 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 336 KB | Output is correct |
2 | Correct | 0 ms | 336 KB | Output is correct |
3 | Correct | 0 ms | 336 KB | Output is correct |
4 | Correct | 0 ms | 336 KB | Output is correct |
5 | Incorrect | 0 ms | 464 KB | Cop can catch the robber, but start() returned -1 |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 336 KB | Output is correct |
2 | Correct | 0 ms | 336 KB | Output is correct |
3 | Correct | 0 ms | 336 KB | Output is correct |
4 | Incorrect | 165 ms | 8724 KB | Cop can catch the robber, but start() returned -1 |
5 | Halted | 0 ms | 0 KB | - |