Submission #789234

#TimeUsernameProblemLanguageResultExecution timeMemory
789234DenkataRarest Insects (IOI22_insects)C++17
99.95 / 100
51 ms460 KiB
#include<bits/stdc++.h> #include "insects.h" //#include "grader.cpp" using namespace std; int i,j,p,q,n,m,k,cnt,mx,ans,br,mi,mo,pb; int cur_size,distinct; vector <int> st; vector <int> a,b; int used[2006]; void add(int cur_size) { bool fl = false; for(auto i:a) { if(fl) { b.push_back(i); continue; } move_inside(i); st.push_back(i); if(press_button()>cur_size) { //cout<<i<<endl; st.pop_back(); b.push_back(i); move_outside(i); } else br++,used[i] = 1; if(br==cur_size*distinct) { fl = true; } } cnt = cur_size; } void rem() { for(auto i:st) { used[i] = false; br--; move_outside(i); } } int min_cardinality(int N) { n = N; cur_size = 1; j = 1; for(i=0; i<n; i++) { if(used[i]==0) { move_inside(i); if(press_button()>cur_size) { //cout<<i<<endl; move_outside(i); a.push_back(i); } else br++,used[i] = 1; } } distinct = br; int l,r,mid; l = 2; r = n/distinct; ans = 1; cnt = cur_size; while(l<=r)/// { mid = (l+r)/2; st.clear(); b.clear(); if(mid>cnt) { add(mid); } // cout<<mid<<" "<<br<<endl; if(br==mid*distinct) { l = mid+1; ans = mid; a = b; cnt = mid; } else { a = st; rem(); r = mid-1; cnt = ans; } } return ans; } /* */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...