#include "insects.h"
#include <bits/stdc++.h>
std::vector <int> IN;
void inside(int x) {
if (std::find(IN.begin(), IN.end(), x) == IN.end())
IN.push_back(x), move_inside(x);
}
void outside(int x) {
if (std::find(IN.begin(), IN.end(), x) != IN.end())
IN.erase(std::find(IN.begin(), IN.end(), x)), move_outside(x);
}
int ask() {
return press_button();
}
std::vector <int> invert(std::vector <int> v, int n) {
std::vector <int> u;
std::sort(v.begin(), v.end());
for (int i = 0, j = 0; i < n; i++) {
if (j < (int) v.size() && v[j] == i) {
j++;
continue;
}
u.push_back(i);
}
return u;
}
int min_cardinality(int n) {
std::vector <int> in, pool;
for (int i = 0; i < n; i++) {
inside(i);
in.push_back(i);
if (ask() == 1) continue;
outside(i);
in.pop_back();
pool.push_back(i);
}
int uniq = in.size();
int ans = 1;
for (int l = 2, r = n / uniq; l <= r; ) {
int mid = (l + r) >> 1;
in.clear();
std::vector <int> new_pool;
for (int i : pool) {
inside(i);
in.push_back(i);
if (ask() > mid) {
outside(i);
in.pop_back();
new_pool.push_back(i);
continue;
}
}
pool = new_pool;
if ((int) IN.size() == uniq * mid) {
ans = mid;
l = mid + 1;
} else {
r = mid - 1;
pool = in;
for (int x : in) {
move_outside(x);
}
}
}
return ans;
}
# |
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 |
2 ms |
432 KB |
Output is correct |
7 |
Correct |
2 ms |
600 KB |
Output is correct |
8 |
Correct |
4 ms |
344 KB |
Output is correct |
9 |
Incorrect |
2 ms |
344 KB |
Wrong answer. |
10 |
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 |
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 |
2 ms |
432 KB |
Output is correct |
7 |
Correct |
2 ms |
600 KB |
Output is correct |
8 |
Correct |
4 ms |
344 KB |
Output is correct |
9 |
Incorrect |
2 ms |
344 KB |
Wrong answer. |
10 |
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 |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
33 ms |
688 KB |
Output is correct |
8 |
Correct |
8 ms |
600 KB |
Output is correct |
9 |
Correct |
30 ms |
604 KB |
Output is correct |
10 |
Partially correct |
33 ms |
600 KB |
Output is partially correct |
11 |
Incorrect |
17 ms |
1108 KB |
Wrong answer. |
12 |
Halted |
0 ms |
0 KB |
- |