제출 #693770

#제출 시각아이디문제언어결과실행 시간메모리
693770T0p_게임 (IOI14_game)C++14
15 / 100
1 ms340 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; int n; int pa[1500], sz[1500], cnt[1500][1500]; bool head[1500]; int fp(int u) { return pa[u] = (u == pa[u]) ? u : fp(pa[u]); } void initialize(int N) { n = N; for (int i=0 ; i<n ; i++) { pa[i] = i; sz[i] = 1; head[i] = true; } } int hasEdge(int u, int v) { u = fp(u); v = fp(v); if (u == v) return 0; if (u > v) swap(u, v); cnt[u][v] += 1; if (cnt[u][v] != sz[u] * sz[v]) return 0; for (int i=0 ; i<u ; i++) if (head[i]) cnt[i][u] += cnt[i][v]; for (int i=u+1 ; i<n ; i++) if (head[i]) cnt[u][i] += cnt[v][i]; pa[v] = u; sz[u] += sz[v]; head[v] = false; return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...