Submission #529102

#TimeUsernameProblemLanguageResultExecution timeMemory
529102GurbanGame (IOI14_game)C++17
15 / 100
1 ms588 KiB
#include "bits/stdc++.h" #include "game.h" using namespace std; using ll = long long; const int maxn=1505; int p[maxn],sz[maxn]; map<int,int>m[maxn]; void initialize(int n) { for(int i = 0;i < n;i++){ p[i] = i; sz[i] = 1; } } int ata(int x){ if(p[x] == x) return x; return p[x] = ata(p[x]); } int hasEdge(int u, int v) { u = ata(u); v = ata(v); if(u == v) exit(0); if((int)m[u].size() < (int)m[v].size()) swap(u,v); int now = 0; if(m[v].find(u) != m[v].end()) now = m[v][u]; if(now == sz[u] * sz[v] - 1){ for(auto j : m[v]){ m[u][j.first] += j.second; if(m[j.first].find(v) != m[j.first].end()) m[j.first].erase(v); m[j.first][u] += j.second; } m[v].clear(); if(m[u].find(v) != m[u].end()) m[u].erase(v); p[v] = u; sz[u] += sz[v]; sz[v] = 0; return 1; } m[u][v]++; m[v][u]++; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...