Submission #38535

#TimeUsernameProblemLanguageResultExecution timeMemory
38535WaschbarCop and Robber (BOI14_coprobber)C++14
0 / 100
214 ms262144 KiB
#include<bits/stdc++.h> #include "coprobber.h" int n, s, timer; int p[1000], tin[1000], tout[1000]; bool ind; bool g[1000][1000]; bool used[1000]; void DFS(int f, int pr) { p[f] = pr; tin[f] = ++timer; used[f] = 1; for(int i = 0; i < n; i++) { if(!g[f][i] || i == pr) continue; if(used[i]) ind = 1; DFS(i,f); } tout[f] = timer; } bool upper(int x, int y) { return ((tin[x] <= tin[y]) && (tout[x] >= tout[y])); } int start(int N, bool A[MAX_N][MAX_N]) { n = N; s = 0; for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) g[i][j] = A[i][j]; DFS(0, -1); if(ind) return -1; return 0; } int nextMove(int R) { for(int i = 0; i < n; i++) { if(!g[s][i] || i == p[s]) continue; if(upper(i,R)) return i; } return -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...