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 <iostream>
#include <cstdio>
#include <set>
#include <vector>
using namespace std;
int dsu[2010];
int rem[2010];
int find(int u){
return dsu[u] == u ? u : dsu[u] = find(dsu[u]);
}
void initialize(int n) {
for (int i = 0; i < n; ++i){
dsu[i] = i;
rem[i] = n-1;
}
}
int hasEdge(int u, int v) {
int a = find(u);
int b = find(v);
rem[a]--;
rem[b]--;
if(a == b){
return 0;
}
if(rem[a] == 0 || rem[b] == 0){
rem[b] += rem[a];
dsu[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... |