제출 #672636

#제출 시각아이디문제언어결과실행 시간메모리
672636blue게임 (IOI14_game)C++17
0 / 100
1 ms212 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; using vi = vector<int>; int n; struct dsu { vi par; vi st; dsu() { par = vi(1500, -1); st = vi(1500, 1); for(int i = 0; i < 1500; i++) par[i] = i; } int root(int u) { if(par[u] == u) return u; else return (par[u] = root(par[u])); } void join(int u, int v) { u = root(u); v = root(v); if(u == v) return; if(st[u] < st[v]) swap(u, v); par[v] = u; st[u] += st[v]; } }; dsu ds; int comp; void initialize(int n_) { n = n_; comp = n; } int hasEdge(int u, int v) { if(ds.root(u) == ds.root(v)) return 1; else if(comp == 2) return 0; else { ds.join(u, v); return 1; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...