#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;
int ch[2020];
int min_cardinality(int n){
int cnt=1,mx=0;
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++;
mx=n-i;
}
else{
move_outside(i);
}
}
if(cnt==1) return n;
// for(int i=0;i<n;i++){
// if(ch[i]) continue;
// move_inside(i);
// }
// mx=min(mx,press_button());
// for(int i=0;i<n;i++){
// if(ch[i]) continue;
// move_outside(i);
// }
int l=1,r=min((int)n/cnt+1,mx),now=cnt;
while(l<r){
int mid=(l+r+1)/2;
int cnt2=now;
vector<int> nw;
for(int j=0;j<n;j++){
if(cnt2==mid*cnt) break;
if(ch[j]) continue;
move_inside(j);
int num=press_button();
if(num<=mid){
ch[j]=1;
nw.push_back(j);
cnt2++;
mx=min(mx,n-j);
}
else{
move_outside(j);
}
}
if(cnt2==mid*cnt){
l=mid,now=cnt2;
r=mx;
}
else{
r=mid-1;
for(auto x:nw) move_outside(x),ch[x]=0;
}
}
return l;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 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 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Incorrect |
3 ms |
596 KB |
Wrong answer. |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 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 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Incorrect |
3 ms |
596 KB |
Wrong answer. |
9 |
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 |
Correct |
10 ms |
344 KB |
Output is correct |
8 |
Correct |
7 ms |
600 KB |
Output is correct |
9 |
Incorrect |
35 ms |
940 KB |
Wrong answer. |
10 |
Halted |
0 ms |
0 KB |
- |