#include "insects.h"
#include <bits/stdc++.h>
#define ll long long
#define sz(s) (int)s.size()
#define pb push_back
#define in insert
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
using namespace std;
const int MAX=2e5+10;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
set<int> a;
set<int> b;
set<int> st;
vector<int> pos;
bool check(int m){
vector<int> vec;
vector<int> vec1;
for(int i:b){
move_inside(pos[i]);
if(press_button()>m){
move_outside(pos[i]);
vec1.pb(i);
}
else{
st.in(i);
vec.pb(i);
}
if(sz(st)==m*sz(a)){
for(int x:vec)b.erase(x);
return 1;
}
}
if(sz(st)<m*sz(a)){
for(int x:vec){
move_outside(pos[x]);
st.erase(x);
}
for(int x:vec1)b.erase(x);
}
else{
for(int x:vec)b.erase(x);
}
return (sz(st)==m*sz(a));
}
int min_cardinality(int N){
n=N;
for(int i=0;i<n;i++)pos.pb(i);
shuffle(all(pos),rng);
for(int i=0;i<N;i++){
move_inside(pos[i]);
if(press_button()==2){
b.in(i);
move_outside(pos[i]);
}
else{
st.in(i);
a.in(i);
}
}
int l=1,r=N/sz(a),res=1;
while(l<=r){
int m=(l+r)/2;
if(check(m)){
l=m+1;
res=m;
}
else r=m-1;
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
3 ms |
344 KB |
Output is correct |
9 |
Correct |
3 ms |
344 KB |
Output is correct |
10 |
Correct |
5 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
3 ms |
344 KB |
Output is correct |
13 |
Correct |
2 ms |
452 KB |
Output is correct |
14 |
Correct |
3 ms |
344 KB |
Output is correct |
15 |
Correct |
2 ms |
344 KB |
Output is correct |
16 |
Correct |
3 ms |
452 KB |
Output is correct |
17 |
Correct |
3 ms |
344 KB |
Output is correct |
18 |
Correct |
3 ms |
344 KB |
Output is correct |
19 |
Correct |
3 ms |
448 KB |
Output is correct |
20 |
Correct |
2 ms |
344 KB |
Output is correct |
21 |
Correct |
2 ms |
344 KB |
Output is correct |
22 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
3 ms |
344 KB |
Output is correct |
9 |
Correct |
3 ms |
344 KB |
Output is correct |
10 |
Correct |
5 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
3 ms |
344 KB |
Output is correct |
13 |
Correct |
2 ms |
452 KB |
Output is correct |
14 |
Correct |
3 ms |
344 KB |
Output is correct |
15 |
Correct |
2 ms |
344 KB |
Output is correct |
16 |
Correct |
3 ms |
452 KB |
Output is correct |
17 |
Correct |
3 ms |
344 KB |
Output is correct |
18 |
Correct |
3 ms |
344 KB |
Output is correct |
19 |
Correct |
3 ms |
448 KB |
Output is correct |
20 |
Correct |
2 ms |
344 KB |
Output is correct |
21 |
Correct |
2 ms |
344 KB |
Output is correct |
22 |
Correct |
2 ms |
344 KB |
Output is correct |
23 |
Correct |
8 ms |
344 KB |
Output is correct |
24 |
Correct |
5 ms |
344 KB |
Output is correct |
25 |
Correct |
14 ms |
344 KB |
Output is correct |
26 |
Correct |
17 ms |
344 KB |
Output is correct |
27 |
Correct |
8 ms |
344 KB |
Output is correct |
28 |
Correct |
3 ms |
344 KB |
Output is correct |
29 |
Correct |
12 ms |
488 KB |
Output is correct |
30 |
Correct |
14 ms |
344 KB |
Output is correct |
31 |
Correct |
16 ms |
600 KB |
Output is correct |
32 |
Correct |
11 ms |
484 KB |
Output is correct |
33 |
Correct |
16 ms |
600 KB |
Output is correct |
34 |
Correct |
17 ms |
456 KB |
Output is correct |
35 |
Correct |
17 ms |
600 KB |
Output is correct |
36 |
Correct |
14 ms |
480 KB |
Output is correct |
37 |
Correct |
18 ms |
856 KB |
Output is correct |
38 |
Correct |
15 ms |
344 KB |
Output is correct |
39 |
Correct |
7 ms |
344 KB |
Output is correct |
40 |
Correct |
5 ms |
492 KB |
Output is correct |
41 |
Correct |
6 ms |
344 KB |
Output is correct |
# |
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 |
1 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 |
20 ms |
560 KB |
Output is correct |
8 |
Correct |
14 ms |
656 KB |
Output is correct |
9 |
Correct |
38 ms |
588 KB |
Output is correct |
10 |
Correct |
29 ms |
492 KB |
Output is correct |
11 |
Correct |
33 ms |
600 KB |
Output is correct |
12 |
Correct |
21 ms |
796 KB |
Output is correct |
13 |
Correct |
25 ms |
344 KB |
Output is correct |
14 |
Correct |
33 ms |
652 KB |
Output is correct |
15 |
Correct |
28 ms |
600 KB |
Output is correct |
16 |
Correct |
33 ms |
992 KB |
Output is correct |
17 |
Correct |
43 ms |
848 KB |
Output is correct |
18 |
Correct |
26 ms |
644 KB |
Output is correct |
19 |
Correct |
20 ms |
344 KB |
Output is correct |
20 |
Correct |
29 ms |
600 KB |
Output is correct |
21 |
Correct |
32 ms |
1024 KB |
Output is correct |
22 |
Correct |
28 ms |
1032 KB |
Output is correct |
23 |
Correct |
22 ms |
344 KB |
Output is correct |
24 |
Correct |
16 ms |
592 KB |
Output is correct |
25 |
Correct |
15 ms |
600 KB |
Output is correct |
26 |
Correct |
10 ms |
344 KB |
Output is correct |
27 |
Correct |
27 ms |
1048 KB |
Output is correct |
28 |
Correct |
29 ms |
508 KB |
Output is correct |
29 |
Correct |
23 ms |
344 KB |
Output is correct |
30 |
Correct |
22 ms |
344 KB |
Output is correct |
31 |
Correct |
26 ms |
736 KB |
Output is correct |
32 |
Correct |
22 ms |
1192 KB |
Output is correct |
33 |
Correct |
25 ms |
592 KB |
Output is correct |
34 |
Correct |
43 ms |
488 KB |
Output is correct |
35 |
Correct |
30 ms |
800 KB |
Output is correct |
36 |
Correct |
28 ms |
592 KB |
Output is correct |
37 |
Correct |
36 ms |
600 KB |
Output is correct |
38 |
Correct |
22 ms |
344 KB |
Output is correct |
39 |
Correct |
21 ms |
600 KB |
Output is correct |
40 |
Correct |
29 ms |
460 KB |
Output is correct |
41 |
Correct |
30 ms |
632 KB |
Output is correct |
42 |
Correct |
21 ms |
344 KB |
Output is correct |
43 |
Correct |
5 ms |
344 KB |
Output is correct |
44 |
Correct |
31 ms |
500 KB |
Output is correct |
45 |
Correct |
16 ms |
344 KB |
Output is correct |
46 |
Correct |
13 ms |
564 KB |
Output is correct |
47 |
Correct |
18 ms |
1112 KB |
Output is correct |
48 |
Correct |
15 ms |
676 KB |
Output is correct |