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 g;unordered_set<int> rp;
int c[1501];int ln[1501];int sz[1501];int e[1501][1501];
int f(int a){
while(a!=ln[a])a=ln[a];
return a;
}
void un(int c,int d,int n){
if(sz[c]<sz[d])swap(c,d);
sz[c]+=sz[d];ln[d]=c;rp.erase(d);
for(auto i:rp){
int k=f(i);
e[c][k]=e[k][c]=(e[k][c]+e[k][d]);
}
}
void initialize(int n) {
g=n;
for(int i=0;i<n;i++){ln[i]=i;rp.insert(i);}memset(sz,1,sizeof(sz));
for(int i=0;i<n;i++)for(int j=0;j<n;j++)e[i][j]=1;
}
int hasEdge(int u, int v) {
int cu=f(u),cv=f(v);
if(e[cu][cv]==1){un(cu,cv,g);return 1;}
e[cu][cv]--;e[cv][cu]--;
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... |