Submission #627376

#TimeUsernameProblemLanguageResultExecution timeMemory
627376haojiandanRarest Insects (IOI22_insects)C++17
53.16 / 100
185 ms420 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; int n; int min_cardinality(int _n) { n=_n; vector<int> V; int cnt=0; for (int i=0;i<n;i++) { move_inside(i); if (press_button()>1) move_outside(i),V.push_back(i); else cnt++; } if (cnt==1) return n; int l=2,r=n/cnt,mid,res=1; int lst=1; while (l<=r) { mid=(l+r)>>1; vector<int> V1,V2; int c=0; for (int &x : V) { move_inside(x); if (press_button()>mid) move_outside(x),V2.push_back(x); else c++,V1.push_back(x); } if (c==cnt*(mid-lst)) { res=mid; V.swap(V2); lst=mid; l=mid+1; } else { r=mid-1; for (int &x : V1) move_outside(x); } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...