Submission #1042762

#TimeUsernameProblemLanguageResultExecution timeMemory
1042762NurislamRarest Insects (IOI22_insects)C++17
0 / 100
2 ms344 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() template <class F, class _S> bool chmin(F &u, const _S &v){ bool flag = false; if ( u > v ){ u = v; flag |= true; } return flag; } template <class F, class _S> bool chmax(F &u, const _S &v){ bool flag = false; if ( u < v ){ u = v; flag |= true; } return flag; } int min_cardinality(int n) { vector<int> v; int k = 0; for(int i = 0; i < n; i++){ move_inside(i); if(press_button() == 1){ k++; }else { move_outside(i); v.pb(i); } } //~ for(auto i:v)cout << i << ' '; //~ cout << '\n'; int ans = 1, r = n/k; int cnt = k; int pref = 1; for(int pw = __lg(r); pw >= 0; pw--){ if(pref == r)break; int m = min(pref + (1<<pw), r); vector<int> up, dn; for(int i:v){ move_inside(i); if(press_button() <= m){ dn.pb(i); }else{ up.pb(i); move_outside(i); } } if(k*m == (int)dn.size() + cnt){ ans = m; v = up; cnt += dn.size(); }else{ v = dn; for(auto i:dn)move_outside(i); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...