Submission #693890

#TimeUsernameProblemLanguageResultExecution timeMemory
693890T0p_Game (IOI14_game)C++14
100 / 100
355 ms15776 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; int n; int pa[1500], sz[1500], cnt[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) { u = fp(u); v = fp(v); cnt[u][v] += 1; cnt[v][u] += 1; if (u == v) return 0; if (cnt[u][v] != sz[u] * sz[v]) return 0; for (int i=0 ; i<n ; i++) { cnt[u][i] += cnt[v][i]; cnt[i][u] += cnt[i][v]; } pa[v] = u; sz[u] += sz[v]; return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...