Submission #928619

#TimeUsernameProblemLanguageResultExecution timeMemory
928619OAleksaGame (IOI14_game)C++14
100 / 100
247 ms26456 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; const int N = 1569; int n, p[N], sz[N], c[N][N]; int root(int v) { if (p[v] == v) return v; return p[v] = root(p[v]); } void initialize(int n1) { n = n1; for (int i = 0;i < n;i++) { p[i] = i, sz[i] = 1; } for (int i = 0;i < n;i++) { for (int j = 0;j < n;j++) { if (i == j) continue; c[i][j] = 1; } } } int hasEdge(int u, int v) { int a = root(u); int b = root(v); --c[a][b], --c[b][a]; if (a == b) return 1; if (c[a][b] > 0) return 0; if (sz[a] < sz[b]) swap(a, b); p[b] = a; sz[a] += sz[b]; for (int i = 0;i < n;i++) { if (i == a || i == b) continue; c[a][i] += c[b][i]; c[i][a] += c[b][i]; } return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...