This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |