Submission #628134

#TimeUsernameProblemLanguageResultExecution timeMemory
628134HanksburgerRarest Insects (IOI22_insects)C++17
100 / 100
61 ms308 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; bool a[2005], b[2005]; vector<int> v; int min_cardinality(int n) { srand(time(0)); for (int i=0; i<n; i++) v.push_back(i); random_shuffle(v.begin(), v.end()); int d=0; for (int i:v) { move_inside(i); b[i]=1; d++; if (press_button()>1) { move_outside(i); b[i]=0; d--; } } for (int i:v) { if (b[i]) { move_outside(i); a[i]=1; } } int l=0, r=(n-d)/d, ans=1; while (l<r) { random_shuffle(v.begin(), v.end()); int k=(l+r+1)/2, cnt=0; for (int i:v) { if (a[i]) continue; move_inside(i); b[i]=1; cnt++; if (press_button()>k) { move_outside(i); b[i]=0; cnt--; } if (cnt==k*d) break; } if (cnt==k*d) { for (int i:v) { if (a[i]) continue; if (b[i]) { move_outside(i); a[i]=1; } } ans+=k; r-=k; } else { for (int i:v) { if (a[i]) continue; if (b[i]) { move_outside(i); b[i]=0; } else a[i]=1; } r=k-1; } } return ans+l; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...