제출 #1125202

#제출 시각아이디문제언어결과실행 시간메모리
1125202StefanSebez드문 곤충 (IOI22_insects)C++17
0 / 100
21 ms424 KiB
#include "insects.h" #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define ll long long #define ld long double mt19937 rng(time(0)); int min_cardinality(int n) { vector<int>vals; for(int i=0;i<n;i++){ vals.pb(i);move_inside(i); if(press_button()==2) vals.pop_back(),move_outside(i); } int S=vals.size(); bool skip[n+10]={false},ubacen[n+10]={false}; int l=1,r=n/S,res=1; while(l<=r){ int mid=l+r>>1,ct=0; for(int i=0;i<n;i++) if(ubacen[i]) ct++; vector<int>a,b,ind; for(int i=0;i<n;i++) if(!skip[i]&&!ubacen[i]) ind.pb(i); shuffle(ind.begin(),ind.end(),rng); for(auto i:ind){ if(ubacen[i]||skip[i]) continue; a.pb(i);move_inside(i); if(press_button()>mid) a.pop_back(),b.pb(i),move_outside(i); if(a.size()+ct==mid*S) break; } if(a.size()+ct==mid*S){ res=mid;l=mid+1; for(auto i:a) ubacen[i]=true; } else{ r=min(mid-1,n/res); for(auto i:a) move_outside(i); for(auto i:b) skip[i]=true; } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...