제출 #596497

#제출 시각아이디문제언어결과실행 시간메모리
596497Elias게임 (IOI14_game)C++17
0 / 100
1 ms304 KiB
#include <bits/stdc++.h> #ifndef _DEBUG #include "game.h" #endif using namespace std; vector<int> parent; // logn union find vector<int> remain; int find(int a) { return parent[a] = ((parent[a] == a) ? a : find(parent[a])); } void initialize(int n) { parent = remain = vector<int>(n); for (int i = 0; i < n; i++) { parent[i] = i; remain[i] = n - 1; } } // if the remaining edge in group is queried, it exists, otherwise it doesn't. This guarantees there are at least 2 groups left until the end int hasEdge(int u, int v) { u = find(u); v = find(v); remain[u]--; remain[v]--; if (remain[u] == 0 || remain[v] == 0) { parent[u] = v; remain[v] += remain[u]; return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...