# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1153689 | gustavo_d | Game (IOI14_game) | C++20 | 0 ms | 328 KiB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
struct DSU {
int n; vector<int> pai, sz;
vector<vector<int>> attempts;
DSU(int _n=0): n(_n), pai(_n), sz(_n, 1),
attempts(_n, vector<int> (_n, 0)) {
for (int i=0; i<n; i++) pai[i] = i;
}
bool merge(int a, int b) {
a = find(a), b = find(b);
if (a == b) return false;
attempts[a][b]++;
attempts[b][a]++;
if (attempts[a][b] < sz[a] * sz[b]) return false;
for (int i=0; i<n; i++) {
attempts[b][i] += attempts[a][i];
attempts[i][b] += attempts[i][a];
}
sz[b] += sz[a];
pai[a] = b;
return true;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |