#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using i64 = long long;
void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print(float x) { cerr << x; } void __print(double x) { cerr << x; } void __print(long double x) { cerr << x; } void __print(char x) { cerr << '\'' << x << '\''; } void __print(const char* x) { cerr << '"' << x << '"'; } void __print(const string& x) { cerr << '"' << x << '"'; } void __print(bool x) { cerr << (x ? "true" : "false"); } template<typename T, typename V> void __print(const pair<T, V>& x) { cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}'; } template<typename T> void __print(const T& x) { int f = 0; cerr << '{'; for (auto& i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}"; } void _print() { cerr << "]\n"; } template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#define ln "\n"
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a; i<=b; ++i)
#define ar array
int Bit(int mask, int b) { return (mask >> b) & 1; }
const ll base = 311, MOD = 998244353, M = 1e9 + 7, INF = 1e18;
int min_cardinality(int N) {
set<int> T;
auto add = [&](int x) { T.insert(x); move_inside(x); };
auto del = [&](int x) { T.erase(x); move_outside(x); };
for (int i = 0; i < N; ++i) {
add(i);
if (press_button() > 1)
del(i);
}
int n_species = T.size();
map<int, set<int>> states;
states[1] = T;
states[N] = set<int>();
for (int i = 0; i < N; ++i) states[N].insert(i);
int lo = 2, hi = N / n_species, res = 1;
while (lo <= hi) {
int md = (lo + hi) / 2;
vector<int> just_added;
auto it = states.lower_bound(md)->second;
for (int i : it) if (!T.count(i)) {
add(i);
if (press_button() > md)
del(i);
else
just_added.push_back(i);
}
int x = T.size();
states[md] = T;
if (x >= n_species * md) {
res = md;
lo = md + 1;
}
else {
for (int i : just_added)
del(i);
hi = md - 1;
}
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 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 |
3 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
3 ms |
344 KB |
Output is correct |
9 |
Correct |
3 ms |
460 KB |
Output is correct |
10 |
Correct |
2 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
3 ms |
344 KB |
Output is correct |
13 |
Correct |
5 ms |
460 KB |
Output is correct |
14 |
Correct |
3 ms |
344 KB |
Output is correct |
15 |
Correct |
3 ms |
344 KB |
Output is correct |
16 |
Correct |
3 ms |
596 KB |
Output is correct |
17 |
Correct |
2 ms |
344 KB |
Output is correct |
18 |
Correct |
5 ms |
432 KB |
Output is correct |
19 |
Correct |
5 ms |
344 KB |
Output is correct |
20 |
Correct |
3 ms |
344 KB |
Output is correct |
21 |
Correct |
2 ms |
344 KB |
Output is correct |
22 |
Correct |
2 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 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 |
3 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
3 ms |
344 KB |
Output is correct |
9 |
Correct |
3 ms |
460 KB |
Output is correct |
10 |
Correct |
2 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
3 ms |
344 KB |
Output is correct |
13 |
Correct |
5 ms |
460 KB |
Output is correct |
14 |
Correct |
3 ms |
344 KB |
Output is correct |
15 |
Correct |
3 ms |
344 KB |
Output is correct |
16 |
Correct |
3 ms |
596 KB |
Output is correct |
17 |
Correct |
2 ms |
344 KB |
Output is correct |
18 |
Correct |
5 ms |
432 KB |
Output is correct |
19 |
Correct |
5 ms |
344 KB |
Output is correct |
20 |
Correct |
3 ms |
344 KB |
Output is correct |
21 |
Correct |
2 ms |
344 KB |
Output is correct |
22 |
Correct |
2 ms |
600 KB |
Output is correct |
23 |
Correct |
19 ms |
848 KB |
Output is correct |
24 |
Correct |
7 ms |
468 KB |
Output is correct |
25 |
Correct |
21 ms |
572 KB |
Output is correct |
26 |
Correct |
15 ms |
564 KB |
Output is correct |
27 |
Correct |
23 ms |
344 KB |
Output is correct |
28 |
Correct |
5 ms |
856 KB |
Output is correct |
29 |
Correct |
16 ms |
600 KB |
Output is correct |
30 |
Correct |
14 ms |
440 KB |
Output is correct |
31 |
Correct |
15 ms |
848 KB |
Output is correct |
32 |
Correct |
16 ms |
600 KB |
Output is correct |
33 |
Correct |
17 ms |
804 KB |
Output is correct |
34 |
Correct |
22 ms |
784 KB |
Output is correct |
35 |
Correct |
20 ms |
784 KB |
Output is correct |
36 |
Correct |
15 ms |
556 KB |
Output is correct |
37 |
Correct |
14 ms |
632 KB |
Output is correct |
38 |
Correct |
11 ms |
688 KB |
Output is correct |
39 |
Correct |
9 ms |
344 KB |
Output is correct |
40 |
Correct |
9 ms |
560 KB |
Output is correct |
41 |
Correct |
7 ms |
616 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 |
40 ms |
1412 KB |
Output is correct |
8 |
Correct |
7 ms |
592 KB |
Output is correct |
9 |
Correct |
24 ms |
1200 KB |
Output is correct |
10 |
Correct |
32 ms |
916 KB |
Output is correct |
11 |
Correct |
27 ms |
812 KB |
Output is correct |
12 |
Correct |
15 ms |
856 KB |
Output is correct |
13 |
Correct |
42 ms |
668 KB |
Output is correct |
14 |
Correct |
32 ms |
596 KB |
Output is correct |
15 |
Correct |
30 ms |
1160 KB |
Output is correct |
16 |
Correct |
49 ms |
1160 KB |
Output is correct |
17 |
Correct |
26 ms |
1052 KB |
Output is correct |
18 |
Correct |
38 ms |
1176 KB |
Output is correct |
19 |
Partially correct |
38 ms |
1564 KB |
Output is partially correct |
20 |
Correct |
35 ms |
1360 KB |
Output is correct |
21 |
Correct |
28 ms |
816 KB |
Output is correct |
22 |
Correct |
53 ms |
600 KB |
Output is correct |
23 |
Correct |
25 ms |
660 KB |
Output is correct |
24 |
Correct |
27 ms |
704 KB |
Output is correct |
25 |
Correct |
13 ms |
716 KB |
Output is correct |
26 |
Correct |
9 ms |
600 KB |
Output is correct |
27 |
Correct |
38 ms |
888 KB |
Output is correct |
28 |
Correct |
26 ms |
1236 KB |
Output is correct |
29 |
Partially correct |
27 ms |
1264 KB |
Output is partially correct |
30 |
Partially correct |
29 ms |
1088 KB |
Output is partially correct |
31 |
Correct |
39 ms |
916 KB |
Output is correct |
32 |
Correct |
26 ms |
944 KB |
Output is correct |
33 |
Correct |
26 ms |
848 KB |
Output is correct |
34 |
Correct |
33 ms |
688 KB |
Output is correct |
35 |
Partially correct |
35 ms |
924 KB |
Output is partially correct |
36 |
Partially correct |
39 ms |
956 KB |
Output is partially correct |
37 |
Correct |
32 ms |
688 KB |
Output is correct |
38 |
Correct |
38 ms |
1156 KB |
Output is correct |
39 |
Correct |
27 ms |
812 KB |
Output is correct |
40 |
Correct |
30 ms |
928 KB |
Output is correct |
41 |
Partially correct |
28 ms |
1252 KB |
Output is partially correct |
42 |
Partially correct |
28 ms |
1108 KB |
Output is partially correct |
43 |
Correct |
6 ms |
600 KB |
Output is correct |
44 |
Correct |
28 ms |
600 KB |
Output is correct |
45 |
Correct |
34 ms |
1328 KB |
Output is correct |
46 |
Correct |
10 ms |
704 KB |
Output is correct |
47 |
Correct |
22 ms |
720 KB |
Output is correct |
48 |
Correct |
17 ms |
684 KB |
Output is correct |