Submission #297682

#TimeUsernameProblemLanguageResultExecution timeMemory
297682juckterGame (IOI14_game)C++14
100 / 100
544 ms20472 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; vector<int> sz, rep, act; vector<vector<int>> used; int N; int find(int x) { return rep[x] == x ? x : rep[x] = find(rep[x]); } void join(int u, int v) { if(sz[u] < sz[v]) swap(u, v); for(int i = 0; i < N; i++) { used[u][i] += used[v][i]; used[i][u] += used[i][v]; } sz[u] += sz[v]; rep[v] = u; } void initialize(int n) { N = n; rep.resize(n); sz.resize(n, 1); used.resize(n, vector<int>(n)); iota(rep.begin(), rep.end(), 0); } int hasEdge(int u, int v) { u = find(u); v = find(v); if(u == v) return 0; if(used[u][v] != sz[u] * sz[v] - 1) { used[u][v]++; used[v][u]++; return 0; } else { join(u, v); return 1; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...