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 "game.h"
#include<bits/stdc++.h>
using namespace std;
int par[1569], sz[1569];
int m, cnt[1569][1569];
int find(int x){
return par[x]==x?x:par[x]=find(par[x]);
}
void uni(int a, int b){
if(a<b) swap(a, b);
par[a]=b; sz[b]+=sz[a];
}
void initialize(int n){
m=n; memset(cnt, 0, sizeof(cnt));
for(int i=0; i<n; i++){
par[i]=i; sz[i]=1;
}
}
int hasEdge(int u, int v){
u=find(u); v=find(v);
cnt[u][v]++; cnt[v][u]++;
if(cnt[u][v]==sz[u]*sz[v]){
uni(u, v);
for(int i=0; i<m; i++){
cnt[u][i]+=cnt[v][i];
cnt[i][u]+=cnt[i][v];
}
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... |