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>
using namespace std;
int n;
vector<vector<int>> asked;
vector<int> cnt;
vector<int> par;
int find(int x){
if(x == par[x]) return par[x];
else return par[x] = find(par[x]);
}
void initialize(int n_) {
n = n_;
par.resize(n);
for(int i = 0; i < n; i++) par[i] = i;
cnt.assign(n, 1);
asked.assign(n, vector<int>(n, 0));
}
int hasEdge(int u, int v) {
u = find(u);
v = find(v);
asked[u][v]++;
asked[v][u]++;
if(asked[u][v] != cnt[u]*cnt[v]) return 0;
par[v] = u;
cnt[u] += cnt[v];
for(int i = 0; i < n; i++){
asked[u][i] += asked[v][i];
asked[i][u] += asked[i][v];
}
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... |