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 deg[N], par[N];
bool visit[N];
void initialize(int n){for(int i=0; i<n; i++)par[i]=i,deg[i]=n-1,visit[i]=false;}
int find(int x){
if(par[x] == x)return x;
return par[x] = find(par[x]);
}
int hasEdge(int u, int v){
u = find(u), v = find(v);
if(!visit[u] && !visit[v]){
visit[u]=visit[v]=true;
deg[u] += deg[v]-2;
deg[v]=0; par[v] = u;
return 1;
}
if(u == v)return 0;
else{
if(deg[u] == 0 || deg[v] == 0){
visit[u]=visit[v]=true;
deg[u] += deg[v];
deg[v] = 0;par[v] = u;
return 1;
}
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... |