제출 #288519

#제출 시각아이디문제언어결과실행 시간메모리
288519emil_physmath게임 (IOI14_game)C++17
42 / 100
1061 ms1384 KiB
#include <algorithm> #include "game.h" using namespace std; const int maxN = 1500; int n; bool asked[maxN][maxN]; int par[maxN], sz[maxN]; int Root(int v) { return v == par[v] ? v : par[v] = Root(par[v]); } void Union(int u, int v) { u = Root(u); v = Root(v); if (u == v) return; if (sz[u] > sz[v]) swap(u, v); sz[v] += sz[u]; par[u] = v; } void initialize(int n_) { n = n_; for (int v = 0; v < n; ++v) par[v] = v, sz[v] = 1; } int hasEdge(int u, int v) { asked[u][v] = asked[v][u] = true; for (int x = 0; x < n; ++x) for (int y = 0; y < n; ++y) { if (x == y) continue; if (Root(x) == Root(u) && Root(y) == Root(v) && !asked[x][y]) return 0; } Union(u, v); return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...