제출 #48328

#제출 시각아이디문제언어결과실행 시간메모리
48328wijw111게임 (IOI14_game)C++14
100 / 100
490 ms19084 KiB
#include "game.h" const int N = 2000; int p[N], c[N], cnt[N][N], pn; int find(int a){ return p[a] == a ? a : (p[a] = find(p[a])); } void merge(int a, int b){ p[b] = p[a]; c[a] += c[b]; for(int i=0; i<pn; i++){ cnt[a][i] += cnt[b][i]; cnt[i][a] += cnt[i][b]; } } void initialize(int n) { pn = n; for(int i=0; i<pn; i++){ p[i] = i; c[i] = 1; } } int hasEdge(int u, int v) { u = find(u); v = find(v); cnt[u][v]++; cnt[v][u]++; if(cnt[u][v] == c[u]*c[v]){ merge(u, v); return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...