Submission #1316091

#TimeUsernameProblemLanguageResultExecution timeMemory
1316091khanhphucscratchGame (IOI14_game)C++20
100 / 100
198 ms7096 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; int root[1505], sz[1505], paridx[1505], num[1505], cc = 0; void initialize(int n) { for(int i = 0; i <= n; i++){ root[i] = i; sz[i] = 1; } } int getroot(int u) { if(root[u] == u) return u; else return getroot(root[u]); } bool unite(int u, int v) { u = getroot(u); v = getroot(v); if(u == v) return 0; if(sz[u] < sz[v]) swap(u, v); paridx[v] = ++cc; num[cc] = sz[u] * sz[v]; root[v] = u; sz[u] += sz[v]; return 1; } int hasEdge(int u, int v) { unite(u, v); int target = 0; while(u != v){ if(sz[u] > sz[v]) swap(u, v); target = max(target, paridx[u]); u = root[u]; } if(--num[target] == 0) return 1; else return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...