#include "insects.h"
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <array>
using namespace std;
#ifdef LOCAL
#define eprintf(...) {fprintf(stderr, __VA_ARGS__);fflush(stderr);}
#else
#define eprintf(...) 42
#endif
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
return (ull)rng() % B;
}
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
clock_t startTime;
double getCurrentTime() {
return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
const int N = 2023;
int n;
int d;
int c;
bool used[N];
bool skip[N];
void findDistinct() {
vector<int> p;
for (int i = 0; i < n; i++) {
move_inside(i);
if (press_button() == 1)
p.push_back(i);
else
move_outside(i);
}
for (int i : p) used[i] = true;
d = (int) p.size();
}
bool check(int x) {
c = 0;
for (int i = 0; i < n; i++)
c += used[i];
vector<int> ids;
for (int i = 0; i < n; i++)
if (!used[i] && !skip[i])
ids.push_back(i);
shuffle(all(ids), rng);
vector<int> p, q;
for (int i : ids) {
move_inside(i);
if (press_button() > x)
move_outside(i), q.push_back(i);
else
c++, p.push_back(i);
if (c == x * d)
break;
}
if (c == x * d) {
for (int i : p) used[i] = true;
return true;
} else {
for (int i : p) move_outside(i);
for (int i : q) skip[i] = true;
return false;
}
}
int min_cardinality(int N) {
n = N;
findDistinct();
if (d == 1)
return N;
// if (d == 2) {
// for (int i = 0; i < N; i++)
// if (!used[i])
// move_inside(i);
// return n - press_button();
// }
int l = 1, r = n / d + 1;
while(r - l > 1) {
int mid = (l + r) / 2;
if (check(mid))
l = mid;
else
r = mid, r = min(r, c / d + 1);
}
return l;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
2 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 |
4 ms |
208 KB |
Output is correct |
10 |
Correct |
4 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
6 ms |
208 KB |
Output is correct |
13 |
Correct |
4 ms |
308 KB |
Output is correct |
14 |
Correct |
5 ms |
304 KB |
Output is correct |
15 |
Correct |
4 ms |
304 KB |
Output is correct |
16 |
Correct |
4 ms |
304 KB |
Output is correct |
17 |
Correct |
4 ms |
208 KB |
Output is correct |
18 |
Correct |
2 ms |
208 KB |
Output is correct |
19 |
Correct |
6 ms |
208 KB |
Output is correct |
20 |
Correct |
5 ms |
208 KB |
Output is correct |
21 |
Correct |
5 ms |
208 KB |
Output is correct |
22 |
Correct |
2 ms |
304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
2 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 |
4 ms |
208 KB |
Output is correct |
10 |
Correct |
4 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
6 ms |
208 KB |
Output is correct |
13 |
Correct |
4 ms |
308 KB |
Output is correct |
14 |
Correct |
5 ms |
304 KB |
Output is correct |
15 |
Correct |
4 ms |
304 KB |
Output is correct |
16 |
Correct |
4 ms |
304 KB |
Output is correct |
17 |
Correct |
4 ms |
208 KB |
Output is correct |
18 |
Correct |
2 ms |
208 KB |
Output is correct |
19 |
Correct |
6 ms |
208 KB |
Output is correct |
20 |
Correct |
5 ms |
208 KB |
Output is correct |
21 |
Correct |
5 ms |
208 KB |
Output is correct |
22 |
Correct |
2 ms |
304 KB |
Output is correct |
23 |
Correct |
11 ms |
208 KB |
Output is correct |
24 |
Correct |
9 ms |
208 KB |
Output is correct |
25 |
Correct |
16 ms |
304 KB |
Output is correct |
26 |
Correct |
22 ms |
296 KB |
Output is correct |
27 |
Correct |
18 ms |
292 KB |
Output is correct |
28 |
Correct |
9 ms |
208 KB |
Output is correct |
29 |
Correct |
22 ms |
304 KB |
Output is correct |
30 |
Correct |
34 ms |
208 KB |
Output is correct |
31 |
Correct |
22 ms |
208 KB |
Output is correct |
32 |
Correct |
24 ms |
308 KB |
Output is correct |
33 |
Correct |
25 ms |
308 KB |
Output is correct |
34 |
Correct |
18 ms |
312 KB |
Output is correct |
35 |
Correct |
18 ms |
304 KB |
Output is correct |
36 |
Correct |
22 ms |
296 KB |
Output is correct |
37 |
Correct |
23 ms |
308 KB |
Output is correct |
38 |
Correct |
25 ms |
308 KB |
Output is correct |
39 |
Correct |
21 ms |
208 KB |
Output is correct |
40 |
Correct |
13 ms |
208 KB |
Output is correct |
41 |
Correct |
10 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 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 |
17 ms |
208 KB |
Output is correct |
8 |
Correct |
16 ms |
316 KB |
Output is correct |
9 |
Correct |
32 ms |
300 KB |
Output is correct |
10 |
Correct |
43 ms |
292 KB |
Output is correct |
11 |
Correct |
51 ms |
296 KB |
Output is correct |
12 |
Correct |
24 ms |
300 KB |
Output is correct |
13 |
Correct |
47 ms |
296 KB |
Output is correct |
14 |
Correct |
50 ms |
308 KB |
Output is correct |
15 |
Correct |
35 ms |
316 KB |
Output is correct |
16 |
Correct |
47 ms |
288 KB |
Output is correct |
17 |
Correct |
45 ms |
208 KB |
Output is correct |
18 |
Correct |
39 ms |
292 KB |
Output is correct |
19 |
Correct |
41 ms |
296 KB |
Output is correct |
20 |
Correct |
45 ms |
288 KB |
Output is correct |
21 |
Correct |
30 ms |
416 KB |
Output is correct |
22 |
Correct |
52 ms |
208 KB |
Output is correct |
23 |
Correct |
52 ms |
208 KB |
Output is correct |
24 |
Correct |
50 ms |
304 KB |
Output is correct |
25 |
Correct |
23 ms |
300 KB |
Output is correct |
26 |
Correct |
15 ms |
312 KB |
Output is correct |
27 |
Correct |
48 ms |
288 KB |
Output is correct |
28 |
Correct |
44 ms |
300 KB |
Output is correct |
29 |
Correct |
47 ms |
292 KB |
Output is correct |
30 |
Correct |
37 ms |
300 KB |
Output is correct |
31 |
Correct |
48 ms |
300 KB |
Output is correct |
32 |
Correct |
44 ms |
304 KB |
Output is correct |
33 |
Correct |
47 ms |
296 KB |
Output is correct |
34 |
Correct |
59 ms |
300 KB |
Output is correct |
35 |
Correct |
53 ms |
208 KB |
Output is correct |
36 |
Correct |
40 ms |
300 KB |
Output is correct |
37 |
Correct |
53 ms |
300 KB |
Output is correct |
38 |
Correct |
41 ms |
328 KB |
Output is correct |
39 |
Correct |
37 ms |
304 KB |
Output is correct |
40 |
Correct |
44 ms |
288 KB |
Output is correct |
41 |
Correct |
33 ms |
288 KB |
Output is correct |
42 |
Correct |
40 ms |
296 KB |
Output is correct |
43 |
Correct |
12 ms |
208 KB |
Output is correct |
44 |
Correct |
42 ms |
300 KB |
Output is correct |
45 |
Correct |
32 ms |
292 KB |
Output is correct |
46 |
Correct |
23 ms |
296 KB |
Output is correct |
47 |
Correct |
20 ms |
208 KB |
Output is correct |
48 |
Correct |
24 ms |
296 KB |
Output is correct |