제출 #658609

#제출 시각아이디문제언어결과실행 시간메모리
658609pere_gil드문 곤충 (IOI22_insects)C++17
53.13 / 100
185 ms332 KiB
#include "insects.h" #include "bits/stdc++.h" using namespace std; vector<bool> in; int tot_in; int get(int n){ int res=0; bool in[n]={}; for(int i=0;i<n;i++){ move_inside(i); if(press_button()>1) move_outside(i); else{ res++; in[i]=true; } } for(int i=0;i<n;i++) if(in[i]) move_outside(i); return res; } bool check(int n, int x, int dif){ vector<int> aux; for(int i=0;i<n;i++){ if(in[i]) continue; move_inside(i); if(press_button()>x) move_outside(i); else{ in[i]=true; tot_in++; aux.push_back(i); } if(tot_in==x*dif) return true; } for(int i: aux){ in[i]=false; tot_in--; move_outside(i); } return false; } int min_cardinality(int n) { int dif=get(n); if(dif==1) return n; in.assign(n,false); tot_in=0; int l=1,r=n/dif+1; while(l+1<r){ int med=(l+r)/2; if(check(n,med,dif)) l=med; else r=med; } return l; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...