제출 #383941

#제출 시각아이디문제언어결과실행 시간메모리
383941ijxjdjd게임 (IOI14_game)C++14
100 / 100
495 ms25364 KiB
#include "game.h" const int MAXN = 1500; int par[MAXN]; int rk[MAXN]; int cnt[MAXN][MAXN]; int N; int find(int x) { if (par[x] == x) { return x; } return (par[x] = find(par[x])); } void merge(int x, int y) { int px = find(x); int py = find(y); if (px != py) { par[px] = py; rk[py] += rk[px]; } } void initialize(int n) { N = n; for (int i = 0; i < n; i++) { par[i] = i; rk[i] = 1; } } int hasEdge(int u, int v) { int px = find(u); int py = find(v); if (cnt[px][py] == rk[px]*rk[py]-1) { for (int i = 0; i < N; i++) { cnt[i][py] += cnt[i][px]; cnt[py][i] += cnt[px][i]; } merge(px, py); return 1; } else { cnt[px][py]++; cnt[py][px]++; return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...