#include "insects.h"
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
using namespace std;
using ll = long long;
template<class T, class U> bool chmin(T& a, const U& b) { return a > b ? a = b, true : false; }
template<class T, class U> bool chmax(T& a, const U& b) { return a < b ? a = b, true : false; }
int min_cardinality(int N) {
rep (i, N) move_inside(i);
int x = press_button();
vector<bool> flag(N, true);
int cnt = -1;
int ans = N;
int sm = 0;
rrep2 (t, 1, x + 1) {
int j = -1;
rep (i, N) {
if (flag[i]) {
move_outside(i);
if (press_button() == t - 1) {
j = i;
flag[i] = false;
break;
}
}
}
int cnt2 = 1;
rep (i, j) {
if (flag[i]) {
move_inside(i);
if (press_button() == t) {
flag[i] = false;
++cnt2;
move_outside(i);
}
}
}
sm += cnt2;
if (cnt != cnt2) {
cnt = cnt2;
ans = t;
}
if ((t - 1) * cnt2 + sm == N) return ans;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
2 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
6 ms |
344 KB |
Output is correct |
10 |
Correct |
3 ms |
344 KB |
Output is correct |
11 |
Correct |
44 ms |
344 KB |
Output is correct |
12 |
Correct |
7 ms |
344 KB |
Output is correct |
13 |
Correct |
4 ms |
344 KB |
Output is correct |
14 |
Correct |
3 ms |
344 KB |
Output is correct |
15 |
Correct |
4 ms |
344 KB |
Output is correct |
16 |
Correct |
8 ms |
344 KB |
Output is correct |
17 |
Correct |
3 ms |
344 KB |
Output is correct |
18 |
Correct |
18 ms |
344 KB |
Output is correct |
19 |
Correct |
8 ms |
344 KB |
Output is correct |
20 |
Correct |
7 ms |
344 KB |
Output is correct |
21 |
Correct |
6 ms |
344 KB |
Output is correct |
22 |
Correct |
5 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
2 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
6 ms |
344 KB |
Output is correct |
10 |
Correct |
3 ms |
344 KB |
Output is correct |
11 |
Correct |
44 ms |
344 KB |
Output is correct |
12 |
Correct |
7 ms |
344 KB |
Output is correct |
13 |
Correct |
4 ms |
344 KB |
Output is correct |
14 |
Correct |
3 ms |
344 KB |
Output is correct |
15 |
Correct |
4 ms |
344 KB |
Output is correct |
16 |
Correct |
8 ms |
344 KB |
Output is correct |
17 |
Correct |
3 ms |
344 KB |
Output is correct |
18 |
Correct |
18 ms |
344 KB |
Output is correct |
19 |
Correct |
8 ms |
344 KB |
Output is correct |
20 |
Correct |
7 ms |
344 KB |
Output is correct |
21 |
Correct |
6 ms |
344 KB |
Output is correct |
22 |
Correct |
5 ms |
344 KB |
Output is correct |
23 |
Correct |
0 ms |
344 KB |
Output is correct |
24 |
Correct |
9 ms |
344 KB |
Output is correct |
25 |
Correct |
2 ms |
344 KB |
Output is correct |
26 |
Correct |
83 ms |
344 KB |
Output is correct |
27 |
Correct |
11 ms |
344 KB |
Output is correct |
28 |
Incorrect |
230 ms |
344 KB |
Too many queries. |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
18 ms |
344 KB |
Output is correct |
9 |
Correct |
3 ms |
344 KB |
Output is correct |
10 |
Incorrect |
232 ms |
344 KB |
Too many queries. |
11 |
Halted |
0 ms |
0 KB |
- |