제출 #38901

#제출 시각아이디문제언어결과실행 시간메모리
38901adamczh1게임 (IOI14_game)C++14
0 / 100
0 ms10808 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; struct UnionFind { vector<int> data; int compcnt; void init(int n) { data.assign(n, -1), compcnt=n; } bool unionSet(int x, int y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; compcnt--; } return x != y; } bool findSet(int x, int y) { return root(x) == root(y); } int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { return -data[root(x)]; } } uf; void initialize(int n) { uf.init(n); } int hasEdge(int u, int v) { if(!uf.findSet(u,v) && uf.compcnt>2){ uf.unionSet(u,v); return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...