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;
const int maxn=1501;
int par[maxn];
int cnt[maxn][maxn];
int n;
void initialize(int _n) {
n=_n;
for(int i=0;i<n;i++) par[i]=i;
for(int i=0;i<n;i++) for(int j=0;j<n;j++) cnt[i][j]=1;
}
int find(int node){
return node==par[node]?node:par[node]=find(par[node]);
}
void merge(int a,int b){
a=find(a);b=find(b);
if(a==b) return;
for(int i=0;i<n;i++) cnt[a][i]+=cnt[b][i],cnt[i][a]+=cnt[i][b];
par[b]=a;
}
int hasEdge(int u, int v) {
u=find(u);
v=find(v);
// cout<<cnt[u][v]<<endl;
if(cnt[u][v]==1){
merge(u,v);return 1;
}
cnt[u][v]--,cnt[v][u]--;
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... |