This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
int e[1500][1500];
int degree[1500];
int n;
void initialize(int N)
{
n=N;
for(int i=0;i<n;i++)
degree[i]=n-1;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
e[i][j]=-1;
}
int hasEdge(int u,int v)
{
if(~e[u][v]) return e[u][v];
e[u][v]=e[v][u]=0;
degree[u]--, degree[v]--;
while(degree[u]==1)
{
degree[u]=0;
for(int i=0;i<n;i++)
if(i!=u && e[u][i]==-1)
{
e[u][i]=e[i][u]=1;
degree[i]--;
u=i;
break;
}
}
while(degree[v]==1)
{
degree[v]=0;
for(int i=0;i<n;i++)
if(i!=v && e[v][i]==-1)
{
e[v][i]=e[i][v]=1;
degree[i]--;
v=i;
break;
}
}
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... |