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 <bits/stdc++.h>
using namespace std;
vector<int> vec[MAX_N];
int tin[MAX_N], tout[MAX_N], timer, pos, par[MAX_N];
void dfs(int v, int p)
{
tin[v]=++timer;
par[v]=p;
int ns=vec[v].size();
for(int i=0; i<ns; i++)
{
int to=vec[v][i];
if(to==p) continue;
dfs(to, v);
}
tout[v]=timer;
return;
}
int start(int N, bool A[MAX_N][MAX_N])
{
for(int i=0; i<N; i++)
{
for(int j=0; j<N; j++)
{
if(j==i) continue;
if(A[i][j]) vec[i].push_back(j);
}
}
dfs(0, -1);
pos=0;
return 0;
}
int nextMove(int R)
{
int ns=vec[pos].size();
for(int i=0; i<ns; i++)
{
int to=vec[pos][i];
if(to==par[pos]) continue;
if(tin[to]<=tin[R] && tout[R]<=tout[to])
{
pos=to;
return to;
}
}
return 0;
}
# | 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... |