#include <bits/stdc++.h>
#include "game.h"
using namespace std;
struct DSU {
std::vector<int> parent;
std::vector<int> sz;
DSU(int n) : parent(n), sz(n, 1) {
std::iota(parent.begin(), parent.end(), 0);
}
int find(int i) {
if (parent[i] == i) return i;
return parent[i] = find(parent[i]);
}
void unite(int i, int j) {
int root_i = find(i);
int root_j = find(j);
if (root_i != root_j) {
if (sz[root_i] < sz[root_j]) std::swap(root_i, root_j);
parent[root_j] = root_i;
sz[root_i] += sz[root_j];
}
}
};
DSU* dsu_global;
std::vector<int> degree;
int num_nodes;
void initialize(int n) {
num_nodes = n;
dsu_global = new DSU(n);
degree.assign(n, 0);
}
int hasEdge(int u, int v) {
degree[u]++;
degree[v]++;
if (degree[u] < num_nodes - 1 || degree[v] < num_nodes - 1) {
return 0;
} else {
return 1;
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |