#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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |