Submission #835233

#TimeUsernameProblemLanguageResultExecution timeMemory
835233LiudasGame (IOI14_game)C++17
0 / 100
1 ms336 KiB
#include <iostream> #include <numeric> #include <vector> #include <set> using namespace std; vector<set<int>> can; vector<int> par; int get(int x){ if(par[x] != x){ return par[x] = get(par[x]); } return x; } void merge(int u, int v){ par[u] = v; } void initialize(int N){ par.resize(N); set<int> con; for(int i = 0; i < N; i ++){ con.insert(i); } can.resize(N); for(int i = 0; i < N; i ++){ con.erase(i); can[i] = con; con.insert(i); } iota(par.begin(), par.end(), 0); } int hasEdge(int u, int v){ u = get(u); v = get(v); if(u == v){return 0;} can[u].erase(v); can[v].erase(u); if(can[u].size() == 0){ merge(u, v); return 1; } if(can[v].size() == 0){ merge(v, u); return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...