제출 #132623

#제출 시각아이디문제언어결과실행 시간메모리
132623junodeveloper게임 (IOI14_game)C++14
15 / 100
4 ms532 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; int par[1500], rk[1500]; int cnt[1500][1500], sz[1500]; int pn(int u){return u==par[u]?u:pn(par[u]); } void us(int a, int b) { a=pn(a), b=pn(b); if(rk[a]<rk[b]) swap(a,b); par[b]=a; sz[a]+=sz[b]; if(rk[a]==rk[b])rk[a]++; } void initialize(int n) { int i, j; for(i=0; i<n; i++) { for(j=0; j<n; j++) cnt[i][j] = 0; par[i] = i; sz[i] = 1; } } int hasEdge(int u, int v) { u=pn(u),v=pn(v); if(u==v) return 1; else if(u>v) swap(u,v); cnt[u][v]++; if(cnt[u][v]==sz[u]*sz[v]) { us(u,v); return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...