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];
void initialize(int n){for(int i=0; i<n; i++)par[i]=i,deg[i]=n-1;}
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);
deg[u]--;deg[v]--;
if(u == v)return 0;
else{
if(deg[u] == 0 || deg[v] == 0){
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... |