Submission #48328

#TimeUsernameProblemLanguageResultExecution timeMemory
48328wijw111Game (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...