#include <bits/stdc++.h>
#include "insects.h"
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
using namespace std;
using ll = long long;
bitset<2020> ch;
int min_cardinality(int n){
int cnt=1;
ch[0]=1;
move_inside(0);
for(int i=1;i<n;i++){
move_inside(i);
int num=press_button();
if(num==1){
ch[i]=1;
cnt++;
}
else{
move_outside(i);
}
}
// int ans=1;
// for(int i=2;i<=n;i++){
// int cnt2=0;
// for(int j=0;j<n;j++){
// if(cnt2==cnt) break;
// if(ch[j]) continue;
// move_inside(j);
// int num=press_button();
// if(num==i){
// ch[j]=1;
// cnt2++;
// }
// else{
// move_outside(j);
// }
// }
// if(cnt2!=cnt) break;
// ans=i;
// }
int l=1,r=n/cnt+1;
vector<int> nw;
while(l<r){
int mid=(l+r+1)/2;
int cnt2=cnt;
for(int j=0;j<n;j++){
if(cnt2==mid*cnt) break;
if(ch[j]) continue;
nw.push_back(j);
move_inside(j);
int num=press_button();
if(num<=mid){
ch[j]=1;
cnt2++;
}
else{
move_outside(j);
}
}
if(cnt2==mid*cnt) l=mid;
else{
r=mid-1;
for(auto x:nw) move_outside(x),ch[x]=0;
}
nw.clear();
}
return l;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Incorrect |
4 ms |
340 KB |
Wrong answer. |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Incorrect |
4 ms |
340 KB |
Wrong answer. |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Incorrect |
57 ms |
1160 KB |
Wrong answer. |
8 |
Halted |
0 ms |
0 KB |
- |