Submission #628100

#TimeUsernameProblemLanguageResultExecution timeMemory
628100HanksburgerRarest Insects (IOI22_insects)C++17
0 / 100
51 ms292 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; bool a[2005], b[2005]; vector<int> v; int min_cardinality(int n) { 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) { bool x=0; for (int i:v) { if (a[i]) continue; if (b[i]) { move_outside(i); a[i]=1; } else x=1; } ans+=k; r-=k; if (x) l++; } 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...