제출 #529094

#제출 시각아이디문제언어결과실행 시간메모리
529094Gurban게임 (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); assert(u != v); 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; m[j.first].erase(v); m[j.first][u] += j.second; } m[v].clear(); 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...