제출 #385322

#제출 시각아이디문제언어결과실행 시간메모리
385322ParsaAlizadeh게임 (IOI14_game)C++17
15 / 100
2 ms492 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; int const N = 1510; int n, par[N], sz[N], cnt[N][N]; int find(int u) { return par[u] == -1 ? u : par[u] = find(par[u]); } int merge(int u, int v) { u = find(u), v = find(v); assert(u != v); if (sz[v] > sz[u]) swap(u, v); if (++cnt[u][v] == sz[u] * sz[v]) { par[v] = u; sz[u] += sz[v]; for (int w = 0; w < n; w++) cnt[u][w] += cnt[v][w], cnt[w][u] += cnt[w][v]; return true; } return false; } void initialize(int _n) { n = _n; fill(par, par + n, -1); fill(sz, sz + n, 1); } int hasEdge(int u, int v) { return merge(u, v); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...