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 "game.h"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define bb back
#define ff first
#define ss second
using namespace std;
vector<vector<int> > cnt;
vector<int> par;
int n;
int find(int a) {
if (par[a] == a)
return a;
return par[a] = find(par[a]);
}
void merge(int a, int b) {
par[b] = a;
for (int i = 0; i < n; i++) {
cnt[a][i] += cnt[b][i];
cnt[i][a] += cnt[b][i];
cnt[b][i] = 0, cnt[i][b] = 0;
}
}
void initialize(int N) {
n = N;
par.resize(n), cnt.resize(n, vector<int>(n));
for (int i = 0; i < n; i++)
par[i] = i;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++) {
if (i == j) cnt[i][j] = 0;
else cnt[i][j] = 1;
}
}
int hasEdge(int u, int v) {
int p1 = find(u), p2 = find(v);
cnt[p1][p2]--;
cnt[p2][p1]--;
if (cnt[p1][p2] == 0) {
merge(p1, p2);
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... |