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>
#define MAXN 1505
using namespace std;
int Cmp, Num, N;
class DSU {
public:
int Set[MAXN];
void init(int n) {
for (int i=0; i<=n; i++) {Set[i] = i;}
}
int Find(int x) {
return(Set[x] == x ? x : Set[x] = Find(Set[x]));
}
void Union(int x, int y) {
int p1 = Find(x), p2 = Find(y);
Set[p1] = p2;
if (p1 != p2) {Cmp--;}
}
} UF;
void initialize(int n) {
UF.init(n), N=n;
Cmp = N;
}
int hasEdge(int u, int v) {
Num++;
if (Cmp > 2 || 2*Num == N*(N-1)) {
UF.Union(u,v);
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... |