Submission #762996

#TimeUsernameProblemLanguageResultExecution timeMemory
762996boyliguanhanCop and Robber (BOI14_coprobber)C++17
0 / 100
165 ms8724 KiB
#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 (stderr)

coprobber.cpp: In function 'bool dfs(int, int, int)':
coprobber.cpp:7:32: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
    7 |     if(c==r) return ok[c][r][t]=1;
      |                     ~~~~~~~~~~~^~
coprobber.cpp:15:51: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   15 |                 return vis[c][r][t]=1,inp[c][r][t]=ok[c][r][t]=0;
      |                                       ~~~~~~~~~~~~^~~~~~~~~~~~~~
coprobber.cpp:16:43: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   16 |         return inp[c][r][t]=0,vis[c][r][t]=1;
      |                               ~~~~~~~~~~~~^~
coprobber.cpp:18:69: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   18 |     if(dfs(c,r,1)) return move[c][r] = c,inp[c][r][t]=0,vis[c][r][t]=ok[c][r][t]=1;
      |                                                         ~~~~~~~~~~~~^~~~~~~~~~~~~~
coprobber.cpp:21:60: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   21 |             return move[c][r]=i,inp[c][r][t]=0,vis[c][r][t]=ok[c][r][t]=1;
      |                                                ~~~~~~~~~~~~^~~~~~~~~~~~~~
coprobber.cpp:22:53: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   22 |     return move[c][r]=-1,vis[c][r][t]=1,inp[c][r][t]=0;
      |                                         ~~~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...