#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> uniqu;
vector<int> insects;
int N;
bool check_num(int num) {
vector<bool> used(N, false);
for (int i = 0; i < int(insects.size()); i++) {
move_inside(insects[i]);
if (press_button() >= num) {
move_outside(insects[i]);
continue;
}
used[i] = true;
}
bool valid = true;
for (int i = 0; i < int(uniqu.size()); i++) {
move_inside(uniqu[i]);
if (press_button() != num) {
move_outside(uniqu[i]);
valid = false;
break;
}
move_outside(uniqu[i]);
}
for (int i = 0; i < N; i++) {
if (used[i]) {
move_outside(i);
}
}
return valid;
}
int min_cardinality(int n) {
N = n;
int types = 0;
for (int i = 0; i < N; i++) {
move_inside(i);
if (press_button() > 1) {
move_outside(i);
insects.push_back(i);
continue;
}
types++;
uniqu.push_back(i);
}
/*
int l = 1;
int r = N/types;
while (l < r) {
int m = (l+r)/2;
if (check_num(m)) {
r = m;
} else {
l = m+1;
}
}
return l;*/
for (int i = 1; i <= N/types; i++) {
if (!check_num(i)) {
return i-1;
}
}
return N/types;
}
# |
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 |
240 ms |
344 KB |
Output is correct |
7 |
Correct |
3 ms |
344 KB |
Output is correct |
8 |
Correct |
9 ms |
344 KB |
Output is correct |
9 |
Correct |
11 ms |
344 KB |
Output is correct |
10 |
Correct |
4 ms |
344 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
3 ms |
344 KB |
Output is correct |
13 |
Correct |
3 ms |
344 KB |
Output is correct |
14 |
Correct |
34 ms |
344 KB |
Output is correct |
15 |
Correct |
17 ms |
344 KB |
Output is correct |
16 |
Correct |
19 ms |
344 KB |
Output is correct |
17 |
Correct |
9 ms |
344 KB |
Output is correct |
18 |
Correct |
4 ms |
344 KB |
Output is correct |
19 |
Correct |
6 ms |
436 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 |
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 |
240 ms |
344 KB |
Output is correct |
7 |
Correct |
3 ms |
344 KB |
Output is correct |
8 |
Correct |
9 ms |
344 KB |
Output is correct |
9 |
Correct |
11 ms |
344 KB |
Output is correct |
10 |
Correct |
4 ms |
344 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
3 ms |
344 KB |
Output is correct |
13 |
Correct |
3 ms |
344 KB |
Output is correct |
14 |
Correct |
34 ms |
344 KB |
Output is correct |
15 |
Correct |
17 ms |
344 KB |
Output is correct |
16 |
Correct |
19 ms |
344 KB |
Output is correct |
17 |
Correct |
9 ms |
344 KB |
Output is correct |
18 |
Correct |
4 ms |
344 KB |
Output is correct |
19 |
Correct |
6 ms |
436 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 |
Incorrect |
259 ms |
344 KB |
Too many queries. |
24 |
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 |
596 KB |
Output is correct |
6 |
Partially correct |
0 ms |
344 KB |
Output is partially correct |
7 |
Incorrect |
227 ms |
440 KB |
Too many queries. |
8 |
Halted |
0 ms |
0 KB |
- |