제출 #658590

#제출 시각아이디문제언어결과실행 시간메모리
658590pere_gil드문 곤충 (IOI22_insects)C++17
10 / 100
367 ms300 KiB
#include "insects.h" #include "bits/stdc++.h" using namespace std; const int MAX_N=2005; int p[MAX_N],ele[MAX_N]; int find_set(int n){ return (p[n]==n) ? n : p[n]=find_set(p[n]); } bool same_set(int a, int b){ return find_set(a)==find_set(b); } void union_set(int a, int b){ a=find_set(a),b=find_set(b); if(a==b) return; ele[a]+=ele[b]; p[b]=a; } int min_cardinality(int n) { iota(p,p+MAX_N,0); for(int i=0;i<n;i++) ele[i]=1; for(int i=0;i<n;i++){ move_inside(i); for(int j=i+1;j<n;j++){ if(same_set(i,j)) continue; move_inside(j); if(press_button()==2) union_set(i,j); move_outside(j); } move_outside(i); } int res=1e9; for(int i=0;i<n;i++) res=min(res,ele[find_set(i)]); return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...