#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int min_cardinality(int N) {
vector<int> v, alr_in;
move_inside(0);
v.pb(0);
for (int i = 1; i < N; i++) {
move_inside(i);
if (press_button() != 1) {
move_outside(i);
} else {
v.pb(i);
}
}
int lo = 1, hi = N / (int)v.size(), ans = -1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
vector<int> to_remove = alr_in;
for (int i = 0; i < N; i++) {
if (!binary_search(v.begin(), v.end(), i) && !binary_search(alr_in.begin(), alr_in.end(), i)) {
move_inside(i);
if (press_button() > mid) {
move_outside(i);
} else {
to_remove.pb(i);
}
}
}
if ((int)to_remove.size() == (int)v.size() * (mid - 1)) {
ans = mid;
lo = mid + 1;
alr_in = to_remove;
sort(alr_in.begin(), alr_in.end());
} else {
hi = mid - 1;
for (auto i : to_remove) {
move_outside(i);
}
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
0 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 |
3 ms |
208 KB |
Output is correct |
10 |
Correct |
6 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
8 ms |
208 KB |
Output is correct |
13 |
Correct |
8 ms |
208 KB |
Output is correct |
14 |
Incorrect |
5 ms |
300 KB |
Wrong answer. |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
0 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 |
3 ms |
208 KB |
Output is correct |
10 |
Correct |
6 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
8 ms |
208 KB |
Output is correct |
13 |
Correct |
8 ms |
208 KB |
Output is correct |
14 |
Incorrect |
5 ms |
300 KB |
Wrong answer. |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
42 ms |
296 KB |
Output is correct |
8 |
Correct |
10 ms |
296 KB |
Output is correct |
9 |
Correct |
48 ms |
296 KB |
Output is correct |
10 |
Partially correct |
69 ms |
276 KB |
Output is partially correct |
11 |
Partially correct |
175 ms |
208 KB |
Output is partially correct |
12 |
Correct |
18 ms |
208 KB |
Output is correct |
13 |
Partially correct |
86 ms |
284 KB |
Output is partially correct |
14 |
Partially correct |
91 ms |
280 KB |
Output is partially correct |
15 |
Incorrect |
40 ms |
320 KB |
Wrong answer. |
16 |
Halted |
0 ms |
0 KB |
- |