Submission #118656

#TimeUsernameProblemLanguageResultExecution timeMemory
118656onjo0127Cop and Robber (BOI14_coprobber)C++11
0 / 100
2 ms384 KiB
#include "coprobber.h" #include <bits/stdc++.h> using namespace std; int now, n, D[MAX_N][MAX_N][2], deg[MAX_N][MAX_N], p = -1; bool adj[MAX_N][MAX_N]; void go(int c, int r, int t) { if(D[c][r][t] == 0) return; if(c != r && t == 1 && --deg[c][r] > 0) return; D[c][r][t] = 0; if(t == 0) { for(int i=0; i<n; i++) { if(adj[r][i]) go(c, i, 1); } } else { go(c, r, 0); for(int i=0; i<n; i++) { if(adj[c][i]) go(i, r, 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++) D[i][j][0] = D[i][j][1] = 1; for(int i=0; i<n; i++) for(int j=0; j<n; j++) adj[i][j] = A[i][j], deg[0][i] += A[i][j]; for(int i=1; i<n; i++) for(int j=0; j<n; j++) deg[i][j] = deg[0][j]; for(int i=0; i<n; i++) {go(i, i, 0); go(i, i, 1);} for(int i=0; i<n; i++) { bool fl = 1; for(int j=0; j<n; j++) if(D[i][j][0] == 1) fl = 0; if(fl) { return now = i; } } return -1; } int nextMove(int R) { if(D[now][R][1] == 0 && p != now) return p = now; int mn = 1e9; for(int i=0; i<n; i++) { if(adj[now][i] && D[i][R][1] == 0 && p != i) mn = min(mn, i); } p = now; return now = mn; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...