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>
#define ll long long
#define pb push_back
using namespace std;
const int maxn = 5e2 + 20;
int vertex;
int par[maxn][maxn] , d[maxn][maxn];
bool visited[maxn][maxn][2];
vector<int> adj[maxn];
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(A[i][j])
adj[i].pb(j);
queue<pair<pair<int , int> , bool> > q;
for(int i = 0; i < n; i++)
q.push({{i , i} , 0}) , q.push({{i , i} , 1}) , visited[i][i][0] = visited[i][i][1] = 1;
while(!q.empty())
{
int v = q.front().first.first , u = q.front().first.second;
bool x = q.front().second;
q.pop();
if(x)
{
for(auto w : adj[v])
if(!visited[w][u][0])
{
par[w][u] = v;
q.push({{w , u} , 0});
visited[w][u][0] = 1;
}
if(!visited[v][u][0])
{
par[v][u] = v;
q.push({{v , u} , 0});
visited[v][u][0] = 1;
}
}
else
{
for(auto w : adj[u])
{
d[v][w]++;
if(d[v][w] == (int)adj[w].size())
{
visited[v][w][1] = 1;
q.push({{v , w} , 1});
}
}
}
}
for(int i = 0; i < n; i++)
{
int t = 0;
for(int j = 0; j < n; j++)
t += visited[i][j][0];
if(t == n)
{
vertex = i;
return i;
}
}
return -1;
}
int nextMove(int R)
{
vertex = par[vertex][R];
return vertex;
}
# | 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... |