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<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 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... |