Submission #162706

#TimeUsernameProblemLanguageResultExecution timeMemory
162706RoundMangoGame (IOI14_game)C++14
100 / 100
466 ms25364 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; int path[1500][1500], sz[1500], par[1500], a[1500], n; int find(int x) { if (x == par[x]) return x; return par[x] = find(par[x]); } void stunion(int x, int y) { if (sz[x] < sz[y]) swap(x,y); sz[x] += sz[y]; par[y] = x; for (int j = 0; j < n; j++) { if (j != x && par[j] == j) { path[j][x] += path[j][y]; path[x][j] = path[j][x]; } } } void initialize(int N) { n = N; for (int i = 0; i < n; i++) { par[i] = i; sz[i] = 1; } for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) path[i][j] = 1; } int hasEdge(int u, int v) { v = find(v); u = find(u); if (path[u][v] == 1) { stunion(v,u); return 1; } else { path[v][u]--; path[u][v]--; return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...