Submission #1016803

#TimeUsernameProblemLanguageResultExecution timeMemory
1016803n3rm1nGame (IOI14_game)C++17
100 / 100
227 ms21332 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; cnt[u][v] = 0; cnt[v][u] = 0; for (int i = 0; i < vcnt; ++ i) { if(i == u)continue; if(i == v)continue; cnt[i][u] += cnt[i][v]; cnt[u][i] += cnt[v][i]; } p[v] = u; for (int i = 0; i < vcnt; ++ i) { cnt[i][v] = 0; cnt[v][i] = 0; } cnt[u][v] = 0; return 1; } cnt[u][v] --; cnt[v][u] --; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...