Submission #1074464

#TimeUsernameProblemLanguageResultExecution timeMemory
1074464NicolaikrobRarest Insects (IOI22_insects)C++17
47.51 / 100
140 ms1160 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; typedef vector<int> vi; int tc, n; vi M, IS; void mi(int i) { move_inside(IS[i]); M.push_back(IS[i]); } void mo(int i = 0) { move_outside(M.back()); M.pop_back(); } bool tjek(int g) { int ctr = n; while(M.size() > 1) mo(); for(int i = 1; i < n; i++) { mi(i); if(press_button() > g) ctr--, mo(i); } return (ctr == g*tc); } int min_cardinality(int N) { tc = n = N; IS.resize(n); for(int i = 0; i < n; i++) IS[i] = i; srand(time(NULL)); random_shuffle(IS.begin(), IS.end()); mi(0); for(int i = 1; i < n; i++) { mi(i); if(press_button() > 1) tc--, mo(i); } int l = 1, u = n/tc; while(l < u) { int g = (l+u+1)/2; if(tjek(g)) l = g; else u = g-1; } return l; } /* 11 1 3 3 7 1 3 5 7 5 1 3 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...