제출 #627869

#제출 시각아이디문제언어결과실행 시간메모리
627869Seb게임 (IOI14_game)C++17
0 / 100
1 ms344 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; ll p[1505],sz[1505],q[1505]; ll lider(ll a) { if (p[a]==a) return a; p[a] = lider(p[a]); return p[a]; } void unir(ll a, ll b) { if (sz[b]>sz[a]) swap(a,b); p[b] = a; sz[a] += sz[b]; q[a] += q[b]; return; } void initialize(int n) { ll i; for (i=0;i<n;i++) { p[i] = i; sz[i] = 1; q[i] = n-1; } } int hasEdge(int u, int v) { if (q[lider(u)]==1 || q[lider(v)]==1) { q[lider(u)]--; q[lider(v)]--; unir(lider(u),lider(v)); return 1; } else { q[lider(u)]--; q[lider(v)]--; return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...