제출 #373869

#제출 시각아이디문제언어결과실행 시간메모리
373869urd05게임 (IOI14_game)C++14
100 / 100
615 ms25324 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; int n; int p[1500]; int con[1500][1500]; int find(int a) { return p[a]<0?a:p[a]=find(p[a]); } void merge(int a,int b) { a=find(a); b=find(b); if (a==b) { return; } p[a]+=p[b]; p[b]=a; } void initialize(int nn) { n=nn; memset(p,-1,sizeof(p)); } int hasEdge(int u,int v) { con[find(u)][find(v)]++; con[find(v)][find(u)]++; if (con[find(u)][find(v)]<p[find(u)]*p[find(v)]) { return false; } for(int i=0;i<n;i++) { con[find(i)][find(u)]+=con[find(i)][find(v)]; con[find(u)][find(i)]+=con[find(v)][find(i)]; con[find(i)][find(v)]=0; con[find(v)][find(i)]=0; } merge(u,v); return true; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...