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 <stdio.h>
#define N (1500)
int par[N], d[N], rd[N], e[N][N], m[N][N], nn;
void initialize(int n){
nn=n;
for(int i=0;i<n;i++){
par[i]=i,d[i]=rd[i]=n-1;
for(int j=0; j<n;j++)e[i][j]=i!=j,m[i][j]=0;
}
}
int find(int x){if(par[x] == x)return x;return par[x] = find(par[x]);}
void f(int x){
if(d[x] != 1)return;
for(int i=0; i<nn; i++)if(find(i) == x && rd[i]){
for(int j=0; j<nn; j++)if(e[i][j]){
int y = find(j);
if(rd[i] != 1)while(1);
d[y]--;rd[j]--;d[x]=rd[i]=0;
par[x]=y;
m[i][j]=m[j][i]=1;
e[i][j]=e[j][i]=0;
f(y);
break;
}
break;
}
}
int hasEdge(int u, int v){
if(m[u][v])return 1;
else if(e[u][v]==0)return 0;
int a=find(u), b=find(v);
d[a]--;d[b]--;
rd[u]--;rd[v]--;
e[u][v]=e[v][u]=0;
f(a);f(b);
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... |