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<bits/stdc++.h>
#define ll long long
#define vl vector<ll>
#include "game.h"
using namespace std;
const int sz = 1505;
struct DSU{
vl e, ne;
void init(ll n){
e.assign(n+1, -1);
ne.assign(n+1, 0);
}
ll base(ll x){
if(e[x] < 0){
return x;
}
return e[x] = base(e[x]);
}
bool unite(ll x, ll y){
x = base(x);
y = base(y);
/*if(x == y){
ll fe = (e[x] * (e[x] + 1) / 2);
ne[x]++;
if(ne[x] == fe){
as = 1;
}
return as;
}
if(e[x] == -1 && e[y] == -1){as = 1;}*/
if(e[x] > e[y]){
swap(x, y);
}
if(x != y){e[x] += e[y];e[y] = x;}
ll fe = (e[x] * (e[x] + 1) / 2);
ne[x]++;
if(x != y){ne[x] += ne[y], ne[y] = 0;}
return ne[x] == fe;
}
};
DSU dsu;
void initialize(int n) {
dsu.init(n);
}
int hasEdge(int u, int v) {
return dsu.unite(u, v);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |