#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ii = pair<int, int>;
bool gasit = false;
vi Perm;
void move_inside2(int p) {
move_inside(Perm[p]);
}
void move_outside2(int p) {
move_outside(Perm[p]);
}
set<int> Cur;
vector<ii> cauta(vi Cul, vi V) {
vector<ii> Re;
if(gasit) return Re;
if(V.empty()) {
gasit = true;
return vector<ii>();
}
if(Cul.size() == 1) {
for(auto it : V) Re.push_back({it, Cul[0]});
return Re;
}
vi C1, C2;
for(int i = 0; i < int(Cul.size()) / 2; ++i) {
C1.push_back(Cul[i]);
}
for(int i = int(Cul.size()) / 2; i < int(Cul.size()); ++i) {
C2.push_back(Cul[i]);
}
set<int> SC1;
for(auto it : C1) SC1.insert(it);
vi de_scos;
for(auto it : Cur) {
if(!SC1.count(it))
de_scos.push_back(it);
}
for(auto it : de_scos) {
Cur.erase(it);
move_outside2(it);
}
for(auto it : C1) {
if(!Cur.count(it)) {
move_inside2(it);
Cur.insert(it);
}
}
vi V1, V2;
for(auto it : V) {
move_inside2(it);
if(press_button() == 2) V1.push_back(it);
else V2.push_back(it);
move_outside2(it);
}
// for(auto it : C1) {
// move_outside2(it);
// }
auto Re1 = cauta(C1, V1), Re2 = cauta(C2, V2);
for(auto it : Re1) Re.push_back(it);
for(auto it : Re2) Re.push_back(it);
return Re;
}
int min_cardinality(int n) {
Perm.clear();
for(int i = 0; i < n; ++i)
Perm.push_back(i);
mt19937 rng(71);
shuffle(Perm.begin(), Perm.end(), rng);
vi Cul, Rest;
for(int i = 0; i < n; ++i) {
move_inside2(i);
if(press_button() == 1) {
Cul.push_back(i);
} else {
move_outside2(i);
Rest.push_back(i);
}
}
for(auto it : Cul) move_outside2(it);
if(Cul.size() > Rest.size()) return 1;
auto Per = cauta(Cul, Rest);
if(gasit) return 1;
map<int, int> Fr;
for(auto it : Cul) ++Fr[it];
for(auto [p, cul] : Per) ++Fr[cul];
int mi = n;
for(auto [cul, fr] : Fr) mi = min(mi, fr);
return mi;
}
# |
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 |
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 |
600 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
4 ms |
604 KB |
Output is correct |
9 |
Correct |
3 ms |
344 KB |
Output is correct |
10 |
Correct |
2 ms |
444 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
2 ms |
344 KB |
Output is correct |
13 |
Correct |
3 ms |
440 KB |
Output is correct |
14 |
Correct |
4 ms |
344 KB |
Output is correct |
15 |
Correct |
2 ms |
440 KB |
Output is correct |
16 |
Correct |
4 ms |
452 KB |
Output is correct |
17 |
Correct |
4 ms |
448 KB |
Output is correct |
18 |
Correct |
4 ms |
604 KB |
Output is correct |
19 |
Correct |
6 ms |
700 KB |
Output is correct |
20 |
Correct |
6 ms |
456 KB |
Output is correct |
21 |
Correct |
2 ms |
596 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
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 |
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 |
600 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
4 ms |
604 KB |
Output is correct |
9 |
Correct |
3 ms |
344 KB |
Output is correct |
10 |
Correct |
2 ms |
444 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
2 ms |
344 KB |
Output is correct |
13 |
Correct |
3 ms |
440 KB |
Output is correct |
14 |
Correct |
4 ms |
344 KB |
Output is correct |
15 |
Correct |
2 ms |
440 KB |
Output is correct |
16 |
Correct |
4 ms |
452 KB |
Output is correct |
17 |
Correct |
4 ms |
448 KB |
Output is correct |
18 |
Correct |
4 ms |
604 KB |
Output is correct |
19 |
Correct |
6 ms |
700 KB |
Output is correct |
20 |
Correct |
6 ms |
456 KB |
Output is correct |
21 |
Correct |
2 ms |
596 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
5 ms |
452 KB |
Output is correct |
24 |
Correct |
5 ms |
448 KB |
Output is correct |
25 |
Correct |
23 ms |
464 KB |
Output is correct |
26 |
Correct |
22 ms |
344 KB |
Output is correct |
27 |
Correct |
11 ms |
340 KB |
Output is correct |
28 |
Correct |
5 ms |
344 KB |
Output is correct |
29 |
Correct |
17 ms |
460 KB |
Output is correct |
30 |
Correct |
21 ms |
956 KB |
Output is correct |
31 |
Correct |
15 ms |
456 KB |
Output is correct |
32 |
Correct |
27 ms |
604 KB |
Output is correct |
33 |
Correct |
21 ms |
484 KB |
Output is correct |
34 |
Correct |
12 ms |
592 KB |
Output is correct |
35 |
Correct |
16 ms |
848 KB |
Output is correct |
36 |
Correct |
29 ms |
696 KB |
Output is correct |
37 |
Correct |
37 ms |
852 KB |
Output is correct |
38 |
Correct |
37 ms |
716 KB |
Output is correct |
39 |
Correct |
33 ms |
696 KB |
Output is correct |
40 |
Correct |
9 ms |
600 KB |
Output is correct |
41 |
Correct |
3 ms |
344 KB |
Output is correct |
# |
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 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
9 ms |
712 KB |
Output is correct |
8 |
Correct |
8 ms |
464 KB |
Output is correct |
9 |
Partially correct |
60 ms |
720 KB |
Output is partially correct |
10 |
Partially correct |
62 ms |
868 KB |
Output is partially correct |
11 |
Correct |
10 ms |
340 KB |
Output is correct |
12 |
Partially correct |
51 ms |
1300 KB |
Output is partially correct |
13 |
Partially correct |
28 ms |
696 KB |
Output is partially correct |
14 |
Partially correct |
70 ms |
736 KB |
Output is partially correct |
15 |
Partially correct |
38 ms |
704 KB |
Output is partially correct |
16 |
Partially correct |
48 ms |
952 KB |
Output is partially correct |
17 |
Partially correct |
36 ms |
872 KB |
Output is partially correct |
18 |
Partially correct |
38 ms |
496 KB |
Output is partially correct |
19 |
Partially correct |
47 ms |
600 KB |
Output is partially correct |
20 |
Partially correct |
51 ms |
592 KB |
Output is partially correct |
21 |
Partially correct |
57 ms |
732 KB |
Output is partially correct |
22 |
Partially correct |
72 ms |
968 KB |
Output is partially correct |
23 |
Partially correct |
64 ms |
740 KB |
Output is partially correct |
24 |
Correct |
22 ms |
600 KB |
Output is correct |
25 |
Correct |
18 ms |
600 KB |
Output is correct |
26 |
Correct |
10 ms |
344 KB |
Output is correct |
27 |
Partially correct |
69 ms |
724 KB |
Output is partially correct |
28 |
Partially correct |
58 ms |
976 KB |
Output is partially correct |
29 |
Partially correct |
54 ms |
712 KB |
Output is partially correct |
30 |
Partially correct |
66 ms |
848 KB |
Output is partially correct |
31 |
Partially correct |
51 ms |
740 KB |
Output is partially correct |
32 |
Partially correct |
51 ms |
752 KB |
Output is partially correct |
33 |
Partially correct |
80 ms |
716 KB |
Output is partially correct |
34 |
Partially correct |
65 ms |
504 KB |
Output is partially correct |
35 |
Partially correct |
65 ms |
600 KB |
Output is partially correct |
36 |
Partially correct |
64 ms |
736 KB |
Output is partially correct |
37 |
Partially correct |
64 ms |
944 KB |
Output is partially correct |
38 |
Partially correct |
68 ms |
344 KB |
Output is partially correct |
39 |
Partially correct |
83 ms |
732 KB |
Output is partially correct |
40 |
Partially correct |
71 ms |
852 KB |
Output is partially correct |
41 |
Partially correct |
59 ms |
592 KB |
Output is partially correct |
42 |
Partially correct |
56 ms |
592 KB |
Output is partially correct |
43 |
Partially correct |
5 ms |
340 KB |
Output is partially correct |
44 |
Partially correct |
40 ms |
456 KB |
Output is partially correct |
45 |
Correct |
23 ms |
444 KB |
Output is correct |
46 |
Partially correct |
49 ms |
1244 KB |
Output is partially correct |
47 |
Partially correct |
55 ms |
1012 KB |
Output is partially correct |
48 |
Partially correct |
50 ms |
684 KB |
Output is partially correct |