This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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); V.swap(V1);
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |