#include <bits/stdc++.h>
using namespace std;
void move_inside(int i);
void move_outside(int i);
int press_button();
bool vis[2222];
int min_cardinality(int n){
vector<int> v;
for(int i=0;i<n;i++){
move_inside(i);
int r = press_button();
if(r == 2) move_outside(i);
else{
v.push_back(i);
vis[i] = 1;
}
}
int ans = n/(int)v.size();
int lo = 1, hi = ans-1;
vector<int> add;
int cnt = 0;
int k = 1;
while(lo <= hi){
int mid = (lo+hi)/2;
if(mid >= k){
for(int i=0;i<n;i++){
if(vis[i]) continue;
if(cnt == (int)v.size()*mid){
break;
}
move_inside(i);
int r = press_button();
k = r;
if(r == mid+2){
move_outside(i);
k = r-1;
}
else{
vis[i] = 1;
add.push_back(i);
cnt++;
}
}
}
else{
vector<int> out;
while(!add.empty()){
int i = add.back();
move_outside(i);
vis[i] = 0;
add.pop_back();
cnt--;
out.push_back(i);
int r = press_button();
k = r;
if(r < mid+2){
break;
}
}
for(int j=0;j<(int)out.size();j++){
int i = out[j];
if(vis[i]) continue;
if(cnt == (int)v.size()*mid){
break;
}
move_inside(i);
int r = press_button();
k = r;
if(r == mid+2){
move_outside(i);
k = r-1;
}
else{
vis[i] = 1;
add.push_back(i);
cnt++;
}
}
}
if(cnt < (int)v.size()*mid) ans = mid, hi = mid-1;
else lo = mid+1;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
4 ms |
208 KB |
Output is correct |
7 |
Correct |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
4 ms |
208 KB |
Output is correct |
9 |
Correct |
5 ms |
208 KB |
Output is correct |
10 |
Correct |
2 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
6 ms |
208 KB |
Output is correct |
13 |
Correct |
7 ms |
208 KB |
Output is correct |
14 |
Correct |
6 ms |
208 KB |
Output is correct |
15 |
Correct |
5 ms |
208 KB |
Output is correct |
16 |
Correct |
5 ms |
208 KB |
Output is correct |
17 |
Correct |
6 ms |
208 KB |
Output is correct |
18 |
Correct |
6 ms |
208 KB |
Output is correct |
19 |
Correct |
6 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
3 ms |
208 KB |
Output is correct |
22 |
Correct |
2 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
4 ms |
208 KB |
Output is correct |
7 |
Correct |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
4 ms |
208 KB |
Output is correct |
9 |
Correct |
5 ms |
208 KB |
Output is correct |
10 |
Correct |
2 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
6 ms |
208 KB |
Output is correct |
13 |
Correct |
7 ms |
208 KB |
Output is correct |
14 |
Correct |
6 ms |
208 KB |
Output is correct |
15 |
Correct |
5 ms |
208 KB |
Output is correct |
16 |
Correct |
5 ms |
208 KB |
Output is correct |
17 |
Correct |
6 ms |
208 KB |
Output is correct |
18 |
Correct |
6 ms |
208 KB |
Output is correct |
19 |
Correct |
6 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
3 ms |
208 KB |
Output is correct |
22 |
Correct |
2 ms |
208 KB |
Output is correct |
23 |
Correct |
13 ms |
284 KB |
Output is correct |
24 |
Correct |
9 ms |
208 KB |
Output is correct |
25 |
Correct |
10 ms |
312 KB |
Output is correct |
26 |
Correct |
30 ms |
424 KB |
Output is correct |
27 |
Correct |
24 ms |
208 KB |
Output is correct |
28 |
Correct |
10 ms |
304 KB |
Output is correct |
29 |
Correct |
37 ms |
296 KB |
Output is correct |
30 |
Correct |
33 ms |
300 KB |
Output is correct |
31 |
Correct |
22 ms |
284 KB |
Output is correct |
32 |
Correct |
24 ms |
284 KB |
Output is correct |
33 |
Correct |
27 ms |
208 KB |
Output is correct |
34 |
Correct |
21 ms |
304 KB |
Output is correct |
35 |
Correct |
24 ms |
208 KB |
Output is correct |
36 |
Correct |
23 ms |
304 KB |
Output is correct |
37 |
Correct |
28 ms |
208 KB |
Output is correct |
38 |
Correct |
29 ms |
284 KB |
Output is correct |
39 |
Correct |
16 ms |
308 KB |
Output is correct |
40 |
Correct |
15 ms |
288 KB |
Output is correct |
41 |
Correct |
6 ms |
308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
30 ms |
288 KB |
Output is correct |
8 |
Correct |
19 ms |
208 KB |
Output is correct |
9 |
Correct |
47 ms |
288 KB |
Output is correct |
10 |
Partially correct |
46 ms |
292 KB |
Output is partially correct |
11 |
Correct |
25 ms |
328 KB |
Output is correct |
12 |
Correct |
26 ms |
208 KB |
Output is correct |
13 |
Partially correct |
71 ms |
280 KB |
Output is partially correct |
14 |
Partially correct |
60 ms |
280 KB |
Output is partially correct |
15 |
Correct |
20 ms |
328 KB |
Output is correct |
16 |
Correct |
46 ms |
292 KB |
Output is correct |
17 |
Correct |
49 ms |
208 KB |
Output is correct |
18 |
Correct |
48 ms |
292 KB |
Output is correct |
19 |
Correct |
37 ms |
208 KB |
Output is correct |
20 |
Correct |
53 ms |
292 KB |
Output is correct |
21 |
Partially correct |
58 ms |
328 KB |
Output is partially correct |
22 |
Partially correct |
64 ms |
280 KB |
Output is partially correct |
23 |
Partially correct |
41 ms |
288 KB |
Output is partially correct |
24 |
Correct |
56 ms |
288 KB |
Output is correct |
25 |
Correct |
25 ms |
208 KB |
Output is correct |
26 |
Correct |
20 ms |
308 KB |
Output is correct |
27 |
Correct |
49 ms |
208 KB |
Output is correct |
28 |
Correct |
28 ms |
284 KB |
Output is correct |
29 |
Correct |
56 ms |
292 KB |
Output is correct |
30 |
Correct |
42 ms |
292 KB |
Output is correct |
31 |
Correct |
57 ms |
296 KB |
Output is correct |
32 |
Partially correct |
60 ms |
208 KB |
Output is partially correct |
33 |
Correct |
41 ms |
208 KB |
Output is correct |
34 |
Correct |
28 ms |
284 KB |
Output is correct |
35 |
Partially correct |
44 ms |
296 KB |
Output is partially correct |
36 |
Correct |
43 ms |
296 KB |
Output is correct |
37 |
Correct |
44 ms |
292 KB |
Output is correct |
38 |
Correct |
46 ms |
292 KB |
Output is correct |
39 |
Correct |
45 ms |
292 KB |
Output is correct |
40 |
Correct |
32 ms |
292 KB |
Output is correct |
41 |
Correct |
33 ms |
284 KB |
Output is correct |
42 |
Partially correct |
44 ms |
336 KB |
Output is partially correct |
43 |
Correct |
11 ms |
208 KB |
Output is correct |
44 |
Correct |
49 ms |
208 KB |
Output is correct |
45 |
Correct |
32 ms |
288 KB |
Output is correct |
46 |
Correct |
23 ms |
208 KB |
Output is correct |
47 |
Correct |
17 ms |
208 KB |
Output is correct |
48 |
Correct |
21 ms |
208 KB |
Output is correct |