Submission #162632

#TimeUsernameProblemLanguageResultExecution timeMemory
162632demetreGame (IOI14_game)C++14
0 / 100
3 ms632 KiB
#include<bits/stdc++.h> using namespace std; int N, n, a, b, f[1001][1001], fix[1001], p[1001]; void initialize (int n) { N = n; for (int i=0; i<N; i++){ p[i] = i; fix[i] = 1; } } int getcol (int l){ if (l == p[l]) return l; return getcol (p[l]); } void col (int k, int l){ int w = getcol(k); int u = getcol(l); p[w] = u; fix[u]+=fix[w]; fix[w] = 0; p[k] = l; for (int i = 0; i < N; i++){ f[u][i]+=f[w][i]; f[i][u]+=f[i][w]; } } int hasEdge (int u, int v){ cin >> a >> b; a = getcol(a); b = getcol(b); f[a][b]++; f[b][a]++; if (f[a][b] == fix[a]*fix[b]){ return 1; if (fix[a] >= fix[b]) swap(a, b); col (a, b); } else return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...