Submission #1007164

#TimeUsernameProblemLanguageResultExecution timeMemory
1007164phoenixGame (IOI14_game)C++17
100 / 100
216 ms18004 KiB
#include "game.h" #include <set> #include <vector> using namespace std; const int N = 1550; int n; int p[N]; int r[N]; int cnt[N][N]; int find(int x) { return p[x] = (p[x] == x ? x : find(p[x])); } void unite(int u, int v) { u = find(u); v = find(v); if (u == v) return; if (r[u] < r[v]) swap(u, v); for (int z = 0; z < n; z++) { cnt[u][z] += cnt[v][z]; cnt[z][u] += cnt[z][v]; cnt[v][z] = cnt[z][v] = 0; } p[v] = u; } void initialize(int _n) { n = _n; for (int i = 0; i < n; i++) { p[i] = i; r[i] = 1; for (int j = 0; j < n; j++) if (i != j) { cnt[i][j] = 1; } } } int hasEdge(int u, int v) { u = find(u); v = find(v); cnt[u][v]--; cnt[v][u]--; if (cnt[u][v]) { return false; } unite(u, v); return true; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...