이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll , ll> ii;
#define ff first
#define ss second
#define pb push_back
#define in insert
const ll N = 1505;
struct DSU{
vector < int > par;
vector < int > sz;
void start(int n){
par.resize(n + 1);
sz.resize(n + 1, 1);
for(int i = 0; i <= n; i++) par[i] = i;
}
int find(int a){
if(a == par[a]) return a;
return par[a] = find(par[a]);
}
void merge(int x, int y){
x = find(x); y = find(y);
if(x == y) return;
par[x] = y;
sz[y] += sz[x];
return;
}
}T;
ll n;
void initialize(int _n) {
n = _n;
T.start(n);
return;
}
int hasEdge(int u, int v) {
if(T.find(u) == T.find(v) || T.sz[T.find(u)] + T.sz[T.find(v)] == n) return 0;
T.merge(u, 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... |