Submission #659051

#TimeUsernameProblemLanguageResultExecution timeMemory
659051Danilo21Game (IOI14_game)C++14
100 / 100
336 ms25180 KiB
#include "game.h" #include <vector> const int mxN = 1510; int N, f[mxN], cnt[mxN][mxN]; int Find(int s){ if (f[s] == s) return s; return f[s] = Find(f[s]); } bool Union(int u, int v){ u = Find(u); v = Find(v); cnt[u][v]--; cnt[v][u]--; if (!cnt[u][v]){ for (int i = 0; i < N; i++){ cnt[u][i] += cnt[v][i]; cnt[i][u] += cnt[i][v]; } f[v] = u; return 1; } return 0; } void initialize(int n){ N = n; for (int i = 0; i < N; i++){ f[i] = i; for (int j = 0; j < N; j++) if (i^j) cnt[i][j] = 1; } } int hasEdge(int u, int v){ return Union(u, v); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...