제출 #715056

#제출 시각아이디문제언어결과실행 시간메모리
715056Ahmed57게임 (IOI14_game)C++14
100 / 100
402 ms25244 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") using namespace std; int pr[1501],gs[1501]; int ed[1501][1501]; int findleader(int x){ if(pr[x]==x){ return x; } return pr[x] = findleader(pr[x]); } int N; void initialize(int n){ N = n; for(int i = 0;i<=n;i++)pr[i] = i,gs[i] = 1; } int hasEdge(int a,int b){ a = findleader(a), b = findleader(b); if(gs[a]<gs[b])swap(a,b); if(gs[a]*gs[b]-1>ed[a][b]){ ed[a][b]++; ed[b][a]++; return 0; } gs[a]+=gs[b]; pr[b]=a; for(int i = 0;i<N;i++){ ed[a][i]+=ed[b][i]; ed[i][a]+=ed[i][b]; } return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...