제출 #139942

#제출 시각아이디문제언어결과실행 시간메모리
139942MrBrionix게임 (IOI14_game)C++14
100 / 100
487 ms23672 KiB
#include <cstdio> #include <cassert> #include "game.h" #include<bits/stdc++.h> using namespace std; int ds[2000],siz[2000],num[2000][2000],tot; void initialize(int n) { tot=n; for(int i=0;i<n;i++){ ds[i]=i; siz[i]=1; } return; } int f(int x){ if(ds[x]!=x)return ds[x]=f(ds[x]); return x; } int hasEdge(int u, int v) { int a=f(u),b=f(v); num[a][b]++; num[b][a]++; if(num[a][b]<(siz[a]*siz[b])) return 0; ds[b]=a; siz[a]+=siz[b]; for(int i=0;i<tot;i++){ num[a][i]+=num[b][i]; num[i][a]+=num[b][i]; } return 1; } /* int read_int() { int x; assert(scanf("%d", &x) == 1); return x; } int main() { int n, u, v; n = read_int(); initialize(n); for (int i = 0; i < n * (n - 1) / 2; i++) { u = read_int(); v = read_int(); printf("%d\n", hasEdge(u, v)); } return 0; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...