Submission #1016795

#TimeUsernameProblemLanguageResultExecution timeMemory
1016795n3rm1nGame (IOI14_game)C++17
0 / 100
1 ms2396 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; const int MAXN = 2e3 + 10; int vcnt; int p[MAXN]; int cnt[MAXN][MAXN]; vector < int > g[MAXN]; void initialize(int n) { vcnt = n; for (int i = 0; i < n; ++ i) p[i] = i; for (int i = 0; i < n; ++ i) { for (int j = 0; j < n; ++ j) if(i != j)cnt[i][j] = 1; } } int find_leader(int i) { if(i == p[i])return i; return (p[i] = find_leader(p[i])); } int hasEdge(int u, int v) { u = find_leader(u); v = find_leader(v); if(u == v) { return 0; } if(cnt[u][v] == 1) { //cout << 1 << endl; for (int i = 0; i < vcnt; ++ i) { if(p[i] == u)continue; if(p[i] == v)continue; cnt[p[i]][u] += cnt[p[i]][v]; cnt[u][p[i]] += cnt[v][p[i]]; } p[v] = u; for (int i = 0; i < vcnt; ++ i) { cnt[i][v] = 0; cnt[v][i] = 0; } return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...