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"
int ed[1515][1515]={},N;
int p[1515];
void initialize(int n) {
N=n;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
ed[i][j]=-1;
}
p[i]=i;
}
}
int find(int x){
if(x==p[x]) return x;
return p[x]=find(p[x]);
}
int hasEdge(int u, int v) {
if(ed[u][v]>=0) return ed[u][v];
if(find(u)==find(v)) return ed[u][v]=ed[v][u]=1;
if(ed[u][N]>=N-2 || ed[v][N]>=N-2) {
p[find(u)]=find(v);
return ed[u][v]=ed[v][u]=1;
}
else{
ed[u][N]++;
ed[v][N]++;
return ed[u][v]=ed[v][u]=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... |