Submission #763040

#TimeUsernameProblemLanguageResultExecution timeMemory
763040boyliguanhanCop and Robber (BOI14_coprobber)C++17
0 / 100
113 ms8692 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) { for(int i = 0; i < n; i++) { if(a[r][i] && !dfs(c, i, 0)) { vis[c][r][t] = 1; inp[c][r][t] = 0; return ok[c][r][t] = 0; } } inp[c][r][t] = 0; return vis[c][r][t] = ok[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:16:36: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   16 |                 return ok[c][r][t] = 0;
      |                        ~~~~~~~~~~~~^~~
coprobber.cpp:20:29: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   20 |         return vis[c][r][t] = ok[c][r][t] = 1;
      |                ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
coprobber.cpp:23:69: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   23 |     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:26:60: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   26 |             return move[c][r]=i,inp[c][r][t]=0,vis[c][r][t]=ok[c][r][t]=1;
      |                                                ~~~~~~~~~~~~^~~~~~~~~~~~~~
coprobber.cpp:27:53: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   27 |     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...