Submission #851835

#TimeUsernameProblemLanguageResultExecution timeMemory
851835ntkphongGame (IOI14_game)C++14
100 / 100
300 ms27376 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; vector<int> par; vector<vector<int>> cnt; int N; int get_root(int u) { return u == par[u] ? u : par[u] = get_root(par[u]); } void initialize(int n) { par.resize(n); for(int i = 0; i < n; i ++) par[i] = i; cnt.resize(n, vector<int> (n, 1)); N = n; } int hasEdge(int u, int v) { u = get_root(u); v = get_root(v); if(u != v) { if(u > v) swap(u, v); cnt[u][v] -- ; if(!cnt[u][v]) { par[v] = u; for(int i = 0; i < N; i ++) { if(i != par[i]) continue ; cnt[min(i, u)][max(i, u)] += cnt[min(i, v)][max(i, v)]; } return 1; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...