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"
using namespace std;
#define pb push_back
vector<vector<int> > graph(MAX_N);
int value[MAX_N][MAX_N][2];
int nxt[MAX_N][MAX_N];
int degree[MAX_N][MAX_N];
vector<array<int,3> > todo;
int pos=0;
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])
graph[i].pb(j);
for(int i=0;i<N;i++)
{
for(int j=0;j<N;j++)
{
if(i==j)
{
todo.pb({i,j,0});
todo.pb({i,j,1});
value[i][j][0]=1;
value[i][j][1]=1;
continue;
}
degree[i][j]+=graph[j].size();
}
}
while(todo.size())
{
vector<array<int,3> > futuretodo;
for(auto d:todo){
int x=d[0],y=d[1],z=d[2];
if(z==1)
{
int i=x,j=y,k=0;
if(value[i][j][k]==0)
{
value[i][j][k]=1;
nxt[i][j]=x;
futuretodo.pb({i,j,k});
}
for(auto p:graph[x])
{
i=p;j=y;k=0;
if(value[i][j][k]==0)
{
value[i][j][k]=1;
nxt[i][j]=x;
futuretodo.pb({i,j,k});
}
}
}
else
{
for(auto p:graph[y])
{
int i=x,j=p,k=1;
if(value[i][j][k]==0)
{
degree[i][j]--;
if(degree[i][j]==0)
{
value[i][j][k]=1;
futuretodo.pb({i,j,k});
}
}
}
}
}
todo=futuretodo;
}
bool t=true;
for(int i=1;i<N;i++)
if(value[0][i][0]!=1)
t=false;
if(t)
return 0;
return -1;
}
int nextMove(int R)
{
return pos=nxt[pos][R];
}
# | 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... |