# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
742661 | 2023-05-16T16:28:57 Z | doowey | Rarest Insects (IOI22_insects) | C++17 | 71 ms | 560 KB |
#include <bits/stdc++.h> #include "insects.h" using namespace std; typedef pair<int, int> pii; #define fi first #define se second #define mp make_pair mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int gen(int m){ return ((int)rng() % m + m) % m; } int min_cardinality(int n) { int val; set<int> in; set<int> st; vector<int> cand; for(int i = 0 ; i < n; i ++ ){ move_inside(i); val = press_button(); cand.push_back(i); if(val > 1){ move_outside(i); } else{ in.insert(i); } } st = in; for(int i = 1; i < n; i ++ ){ swap(cand[i], cand[gen(i + 1)]); } int dist = in.size(); int l = 1; int r = n/dist + 1; int mid; while(l + 1 < r){ mid = (l + r) / 2; if(mid * dist > n){ r = mid; continue; } for(auto i : cand){ if(!in.count(i)){ move_inside(i); val = press_button(); if(val > mid){ move_outside(i); } else{ in.insert(i); } if(in.size() == mid * dist) break; } } if(in.size() == mid * dist){ l = mid; st = in; } else{ r = mid; cand.clear(); for(auto q : in){ if(st.count(q)) continue; move_outside(q); cand.push_back(q); } for(int i = 1; i < cand.size(); i ++ ){ swap(cand[i], cand[gen(i + 1)]); } in = st; } } return l; }
Compilation message
# | 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 | 1 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 | 6 ms | 208 KB | Output is correct |
9 | Correct | 5 ms | 208 KB | Output is correct |
10 | Correct | 6 ms | 208 KB | Output is correct |
11 | Correct | 1 ms | 208 KB | Output is correct |
12 | Correct | 7 ms | 208 KB | Output is correct |
13 | Correct | 6 ms | 300 KB | Output is correct |
14 | Correct | 5 ms | 316 KB | Output is correct |
15 | Correct | 6 ms | 208 KB | Output is correct |
16 | Correct | 4 ms | 208 KB | Output is correct |
17 | Correct | 5 ms | 208 KB | Output is correct |
18 | Correct | 6 ms | 208 KB | Output is correct |
19 | Correct | 7 ms | 208 KB | Output is correct |
20 | Correct | 5 ms | 208 KB | Output is correct |
21 | Correct | 4 ms | 304 KB | Output is correct |
22 | Correct | 3 ms | 208 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 | 1 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 | 6 ms | 208 KB | Output is correct |
9 | Correct | 5 ms | 208 KB | Output is correct |
10 | Correct | 6 ms | 208 KB | Output is correct |
11 | Correct | 1 ms | 208 KB | Output is correct |
12 | Correct | 7 ms | 208 KB | Output is correct |
13 | Correct | 6 ms | 300 KB | Output is correct |
14 | Correct | 5 ms | 316 KB | Output is correct |
15 | Correct | 6 ms | 208 KB | Output is correct |
16 | Correct | 4 ms | 208 KB | Output is correct |
17 | Correct | 5 ms | 208 KB | Output is correct |
18 | Correct | 6 ms | 208 KB | Output is correct |
19 | Correct | 7 ms | 208 KB | Output is correct |
20 | Correct | 5 ms | 208 KB | Output is correct |
21 | Correct | 4 ms | 304 KB | Output is correct |
22 | Correct | 3 ms | 208 KB | Output is correct |
23 | Correct | 21 ms | 304 KB | Output is correct |
24 | Correct | 10 ms | 340 KB | Output is correct |
25 | Correct | 16 ms | 308 KB | Output is correct |
26 | Correct | 21 ms | 312 KB | Output is correct |
27 | Correct | 29 ms | 308 KB | Output is correct |
28 | Correct | 10 ms | 316 KB | Output is correct |
29 | Correct | 25 ms | 304 KB | Output is correct |
30 | Correct | 30 ms | 308 KB | Output is correct |
31 | Correct | 21 ms | 348 KB | Output is correct |
32 | Correct | 25 ms | 360 KB | Output is correct |
33 | Correct | 25 ms | 308 KB | Output is correct |
34 | Correct | 25 ms | 400 KB | Output is correct |
35 | Correct | 26 ms | 432 KB | Output is correct |
36 | Correct | 19 ms | 308 KB | Output is correct |
37 | Correct | 19 ms | 328 KB | Output is correct |
38 | Correct | 22 ms | 208 KB | Output is correct |
39 | Correct | 23 ms | 336 KB | Output is correct |
40 | Correct | 18 ms | 340 KB | Output is correct |
41 | Correct | 11 ms | 328 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 | 0 ms | 208 KB | Output is correct |
6 | Correct | 1 ms | 208 KB | Output is correct |
7 | Correct | 44 ms | 472 KB | Output is correct |
8 | Correct | 24 ms | 464 KB | Output is correct |
9 | Correct | 40 ms | 412 KB | Output is correct |
10 | Correct | 53 ms | 300 KB | Output is correct |
11 | Correct | 36 ms | 304 KB | Output is correct |
12 | Correct | 31 ms | 328 KB | Output is correct |
13 | Correct | 42 ms | 300 KB | Output is correct |
14 | Correct | 60 ms | 316 KB | Output is correct |
15 | Correct | 23 ms | 428 KB | Output is correct |
16 | Correct | 50 ms | 480 KB | Output is correct |
17 | Correct | 43 ms | 440 KB | Output is correct |
18 | Correct | 31 ms | 448 KB | Output is correct |
19 | Correct | 49 ms | 436 KB | Output is correct |
20 | Correct | 55 ms | 428 KB | Output is correct |
21 | Correct | 30 ms | 304 KB | Output is correct |
22 | Correct | 39 ms | 372 KB | Output is correct |
23 | Correct | 42 ms | 312 KB | Output is correct |
24 | Correct | 34 ms | 316 KB | Output is correct |
25 | Correct | 16 ms | 396 KB | Output is correct |
26 | Correct | 23 ms | 356 KB | Output is correct |
27 | Correct | 50 ms | 464 KB | Output is correct |
28 | Correct | 40 ms | 460 KB | Output is correct |
29 | Correct | 39 ms | 456 KB | Output is correct |
30 | Correct | 35 ms | 560 KB | Output is correct |
31 | Correct | 71 ms | 312 KB | Output is correct |
32 | Correct | 61 ms | 312 KB | Output is correct |
33 | Correct | 45 ms | 316 KB | Output is correct |
34 | Correct | 47 ms | 304 KB | Output is correct |
35 | Correct | 47 ms | 496 KB | Output is correct |
36 | Correct | 28 ms | 424 KB | Output is correct |
37 | Correct | 59 ms | 388 KB | Output is correct |
38 | Correct | 52 ms | 300 KB | Output is correct |
39 | Correct | 56 ms | 460 KB | Output is correct |
40 | Correct | 49 ms | 416 KB | Output is correct |
41 | Correct | 59 ms | 432 KB | Output is correct |
42 | Correct | 53 ms | 392 KB | Output is correct |
43 | Correct | 10 ms | 208 KB | Output is correct |
44 | Correct | 21 ms | 312 KB | Output is correct |
45 | Correct | 38 ms | 420 KB | Output is correct |
46 | Correct | 25 ms | 308 KB | Output is correct |
47 | Correct | 32 ms | 316 KB | Output is correct |
48 | Correct | 24 ms | 328 KB | Output is correct |