Submission #41360

#TimeUsernameProblemLanguageResultExecution timeMemory
41360gabrielsimoesCop and Robber (BOI14_coprobber)C++14
16 / 100
232 ms262144 KiB
#include "coprobber.h" #include <vector> int pre[MAX_N], pos[MAX_N], t = 0; int prev[MAX_N]; std::vector<int> g[MAX_N]; void dfs(int cur) { pre[cur] = t++; for (int nx : g[cur]) { if (nx != prev[cur]) { prev[nx] = cur; dfs(nx); } } pos[cur] = t++; } int start(int N, bool A[MAX_N][MAX_N]) { for (int i = 0; i < N; i++) { for (int k = 0; k < N; k++) { if (A[i][k]) { g[i].push_back(k); } } } dfs(0); return 0; } int x = 0; int nextMove(int R) { for (int nx : g[x]) { if (nx != prev[x]) { if (pre[nx] <= pre[R] && pos[nx] >= pos[R]) { return x = nx; } } } return x; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...