Submission #693781

#TimeUsernameProblemLanguageResultExecution timeMemory
693781T0p_Game (IOI14_game)C++14
0 / 100
1 ms212 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; int n; int pa[1500], sz[1500]; bool assigned[1500][1500]; int fp(int u) { return pa[u] = (u == pa[u]) ? u : fp(pa[u]); } void initialize(int N) { n = N; for (int i=0 ; i<n ; i++) { pa[i] = i; sz[i] = 1; } } int hasEdge(int u, int v) { assigned[u][v] = assigned[v][u] = true; int uu = fp(u), vv = fp(v); if (uu == vv) return 0; int cnt = 0; for (int i=0 ; i<n ; i++) if (fp(i) == uu) { for (int j=i+1 ; j<n ; j++) if (fp(j) == vv) { if (assigned[i][j]) cnt += 1; } } if (cnt != sz[uu] * sz[vv]) return 0; pa[uu] = vv; sz[vv] += sz[uu]; return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...