Submission #997628

#TimeUsernameProblemLanguageResultExecution timeMemory
997628daffuwuGame (IOI14_game)C++14
0 / 100
1 ms2648 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; int n, rep[1569], cnt[1569][1569]; int fd(int x) { if (rep[x] != x) rep[x] = fd(rep[x]); return rep[x]; } void initialize(int n) { ::n = n; int i, j; for (i=0; i<=n-1; i++) { rep[i] = i; for (j=i+1; j<=n-1; j++) cnt[i][j] = 1; } } int hasEdge(int u, int v) { int i; if (fd(u)>fd(v)) swap(u, v); if (cnt[fd(u)][fd(v)] == 1) { // u gabung ke v aja for (i=fd(v)+1; i<=n-1; i++) cnt[fd(v)][i] += cnt[fd(u)][i]; rep[fd(u)] = fd(v); return 1; } cnt[fd(u)][fd(v)]--; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...