제출 #576083

#제출 시각아이디문제언어결과실행 시간메모리
576083elazarkoren게임 (IOI14_game)C++17
42 / 100
1092 ms6484 KiB
#include "game.h" #include <bits/stdc++.h> #define x first #define y second #define all(v) v.begin(), v.end() #define chkmin(a, b) a = min(a, b) #define chkmax(a, b) a = max(a, b) using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef vector<pii> vii; struct Dsu { int n; vi par, sz; Dsu() {} Dsu(int n): n(n) { par.resize(n), sz.resize(n, 1); iota(all(par), 0); } int Find(int i) { return par[i] == i ? i : par[i] = Find(par[i]); } void Union(int a, int b) { int pa = Find(a), pb = Find(b); if (pa == pb) return; if (sz[pa] < sz[pb]) swap(pa, pb); par[pb] = pa; sz[pa] += sz[pb]; } }; set<pii> edges; int n; void initialize(int N) { n = N; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { edges.insert({i, j}); } } } int hasEdge(int u, int v) { if (u > v) swap(u, v); Dsu dsu(n); for (auto [a, b] : edges) { if (a != u || b != v) { dsu.Union(a, b); } } if (dsu.sz[dsu.Find(0)] != n) return 1; edges.erase(edges.find({u, v})); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...