# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
936016 | peterandvoi | Game (IOI14_game) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#ifdef ngu
#include "debug.h"
#else
#define debug(...) 42
#endif
vector<vector<int>> cnt;
vector<int> lab;
int get(int u) {
return lab[u] < 0 ? u : lab[u] = get(lab[u]);
}
int hasEdge(int u, int v) {
u = get(u);
v = get(v);
if (cnt[u][v] > 1) }
cnt[u][v]--;
return 0;
}
if (lab[u] > lab[v]) {
swap(u, v);
}
lab[u] += lab[v];
lab[v] = u;
for (int i = 0; i < n; ++i) {
cnt[u][i] += cnt[v][i];
cnt[i][u] = cnt[u][i];
}
return 1;
}
void initialize(int n) {
cnt.resize(n, vector<int>(n));
lab.resize(n, -1);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
cnt[i][j] = i != j;
}
}
}