Submission #226997

#TimeUsernameProblemLanguageResultExecution timeMemory
226997Charis02Game (IOI14_game)C++14
0 / 100
5 ms384 KiB
#include "game.h" #define N 1505 int par[N],edges[N]; int f(int x) { if(par[x]==x) return x; return par[x]=f(par[x]); } bool issameset(int x,int y) { int fx=f(x); int fy = f(y); return (fx==fy); } void join(int x,int y) { if(issameset(x,y)) return; int fx = f(x); int fy = f(y); par[fx] = fy; edges[fy]+=edges[fx]; return; } void initialize(int n) { for(int i = 0;i < n;i++) { edges[i]=n-1; par[i]=i; } return; } int hasEdge(int u, int v) { int fu = f(u); int fv = f(v); edges[fu]--; edges[fv]--; if(edges[fu] == 0 || edges[fv] == 0) { join(u,v); return 1; } else return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...