Submission #513510

#TimeUsernameProblemLanguageResultExecution timeMemory
513510status_codingGame (IOI14_game)C++14
0 / 100
1 ms304 KiB
#include "game.h" #include <bits/stdc++.h> int cnt; int par[2005]; int nr[2005]; int dsu_par(int x) { if(par[x]!=x) par[x]=dsu_par(par[x]); return par[x]; } void dsu_merge(int x, int y) { par[y]=x; nr[x]+=nr[y]-2; cnt--; } void initialize(int n) { cnt = n; for(int i=1;i<=n;i++) { par[i]=i; nr[i]=n-1; } } int hasEdge(int x, int y) { x = dsu_par(x+1); y = dsu_par(y+1); if(x == y) return true; if(cnt > 2 && (nr[x]>=2 || nr[y]>=2)) { dsu_merge(x, y); return true; } if(cnt == 1 && (nr[x]==1 || nr[y]==1)) { dsu_merge(x, y); return true; } nr[x]--; nr[y]--; return false; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...