#include "game.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define st first
#define nd second
#define pb push_back
#define pii pair<int, int>
#define all(a) a.begin(), a.end()
const int MAXN = 1507;
int ojc[MAXN];
int ile[MAXN];
int find(int v) {
if (ojc[v] == v) return v;
int pom = find(ojc[v]);
ojc[v] = pom;
return pom;
}
void Union(int a, int b) {
int u = find(a);
int w = find(b);
ojc[u] = w;
ile[w] += ile[u];
}
void initialize(int n) {
rep(i, n + 1) {
ojc[i] = i;
ile[i] = n - 1;
}
}
int hasEdge(int u, int v) {
int a = find(u);
int b = find(v);
ile[a]--;
ile[b]--;
if (ile[a] == 0 || ile[b] == 0) {
Union(a, b);
return 1;
}
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |