제출 #783312

#제출 시각아이디문제언어결과실행 시간메모리
783312FEDIKUS드문 곤충 (IOI22_insects)C++17
47.50 / 100
159 ms336 KiB
#include "insects.h" #include<bits/stdc++.h> using namespace std; const int maxn=2010; int n; int tren[maxn]; int perm[maxn]; int unutra=0; int korak=1; int raz; void ubaci(int i){ if(tren[i]!=0) return; tren[i]=korak; move_inside(perm[i]); unutra++; } void izbaci(int i){ if(tren[i]==0) return; tren[i]=0; move_outside(perm[i]); unutra--; } int pitaj(){ return press_button(); } int nadji(){ for(int i=0;i<n;i++){ ubaci(i); if(pitaj()>1){ izbaci(i); } } return unutra; } mt19937 rng(23479); bool probaj(int gran){ // da li je >= korak++; for(int i=0;i<n;i++){ ubaci(i); if(pitaj()>gran){ izbaci(i); } } if(unutra==raz*gran) return true; for(int i=0;i<n;i++) if(tren[i]==korak) izbaci(i); return false; } int min_cardinality(int _n){ n=_n; for(int i=0;i<n;i++) perm[i]=i; shuffle(perm,perm+n,rng); raz=nadji(); int l=1,r=n/raz; int res=-1; while(l<=r){ int mid=l+(r-l)/2; if(probaj(mid)){ res=mid; l=mid+1; }else r=mid-1; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...