Submission #256794

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
2567942020-08-03 08:16:10SpeedOfMagicGame (IOI14_game)C++17
15 / 100
2 ms384 KiB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> cnt; // cnt[i][j] = how many edges are forbidden between i and j
vector<int> repr, siz;
int ffind(int a) { return (a == repr[a]) ? a : repr[a] = ffind(repr[a]); }
void unite(int u, int v) { // O(N), O(N^2) amortized
u = ffind(u); v = ffind(v);
if (u == v) return;
if (siz[u] > siz[v]) swap(u, v);
repr[u] = v; siz[v] += siz[u];
for (size_t i = 0; i < cnt.size(); ++i)
cnt[v][i] += cnt[u][i];
}
void initialize(int n) {
cnt.resize(n, vector<int>(n, 0));
repr.resize(n);
for (int i = 0; i < n; ++i)
repr[i] = i;
siz.resize(n, 1);
}
int hasEdge(int u, int v) {
int ru = ffind(u), rv = ffind(v);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...