# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
628871 | 2022-08-13T18:46:15 Z | welleyth | Rarest Insects (IOI22_insects) | C++17 | 188 ms | 384 KB |
#include "insects.h" #include <bits/stdc++.h> using namespace std; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); int CNTQ[3] = {}; int getQ(){ return max(CNTQ[0],max(CNTQ[1],CNTQ[2])); } int min_cardinality(int N) { // for(int i = 0; i < 50; i++){ // cout << i+1 << " " << i+1 << " "; // } // cout << "\n"; // return 0; int col[N]; for(int i = 0; i < N; i++) col[i] = 0; int c = 0; int mn = N; int pos[N+1]; bool was[N]; int pref[N+1]; for(int i = 0; i <= N; i++) pos[i] = -1; for(int i = 0; i < N; i++) was[i] = false; for(int i = 0; i < N; i++) pref[i] = -1; bool in[N]; vector<int> order; for(int i = 0; i < N; i++){ move_inside(i); if(press_button() == 1){ was[i] = 1; pref[i] = order.size(); order.push_back(i); } else { if(i) pref[i] = pref[i-1]; move_outside(i); } } sort(order.begin(),order.end()); c = order.size(); for(int i = 0; i < order.size(); i++){ col[order[i]] = i; pos[col[order[i]]] = order[i]; in[i] = 1; } if(2*c > N){ return 1; } // cerr << "ok\n"; // for(int i = 0; i < c; i++){ // cerr << "pos[i] = " << pos[i] << "\n"; // } for(int bt = 0; (1 << bt) < c; bt++){ for(int i = 0; i < c; i++){ if(pos[i] == -1) continue; if(i >> bt & 1 && !in[i]){ in[i] = 1; move_inside(pos[i]); } if((i >> bt & 1) == 0 && in[i]){ move_outside(pos[i]); in[i] = 0; } } for(int i = 0; i < N; i++){ if(was[i] || pref[i] < (1 << bt)) continue; move_inside(i); int szIn = press_button(); assert(szIn < 3); if(szIn == 2){ col[i] |= (1 << bt); } move_outside(i); } map<int,int> cnt; for(int i = 0; i < N; i++){ if(col[i] >= (1 << bt)) continue; cnt[col[i]]++; } // cerr << "col: "; // for(int i = 0; i < N; i++){ // cerr << col[i] << " "; // } // cerr << "\n"; for(auto&[x,y] : cnt) mn = min(mn,y); if(mn == 1) return 1; } map<int,int> cnt; for(int i = 0; i < N; i++){ cnt[col[i]]++; } for(auto&[x,y] : cnt) mn = min(mn,y); return mn; } /** 6 5 8 9 5 9 9 1 2 3 0 0 0 40 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 100 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 10 1 0 2 0 3 0 4 0 5 0 1 1 **/
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 | 2 ms | 208 KB | Output is correct |
7 | Correct | 2 ms | 208 KB | Output is correct |
8 | Correct | 10 ms | 208 KB | Output is correct |
9 | Correct | 10 ms | 208 KB | Output is correct |
10 | Correct | 5 ms | 208 KB | Output is correct |
11 | Correct | 3 ms | 208 KB | Output is correct |
12 | Correct | 7 ms | 208 KB | Output is correct |
13 | Correct | 8 ms | 208 KB | Output is correct |
14 | Correct | 7 ms | 208 KB | Output is correct |
15 | Correct | 6 ms | 208 KB | Output is correct |
16 | Correct | 10 ms | 208 KB | Output is correct |
17 | Correct | 8 ms | 208 KB | Output is correct |
18 | Correct | 9 ms | 208 KB | Output is correct |
19 | Correct | 5 ms | 208 KB | Output is correct |
20 | Correct | 10 ms | 208 KB | Output is correct |
21 | Correct | 7 ms | 208 KB | Output is correct |
22 | Correct | 2 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 | 2 ms | 208 KB | Output is correct |
7 | Correct | 2 ms | 208 KB | Output is correct |
8 | Correct | 10 ms | 208 KB | Output is correct |
9 | Correct | 10 ms | 208 KB | Output is correct |
10 | Correct | 5 ms | 208 KB | Output is correct |
11 | Correct | 3 ms | 208 KB | Output is correct |
12 | Correct | 7 ms | 208 KB | Output is correct |
13 | Correct | 8 ms | 208 KB | Output is correct |
14 | Correct | 7 ms | 208 KB | Output is correct |
15 | Correct | 6 ms | 208 KB | Output is correct |
16 | Correct | 10 ms | 208 KB | Output is correct |
17 | Correct | 8 ms | 208 KB | Output is correct |
18 | Correct | 9 ms | 208 KB | Output is correct |
19 | Correct | 5 ms | 208 KB | Output is correct |
20 | Correct | 10 ms | 208 KB | Output is correct |
21 | Correct | 7 ms | 208 KB | Output is correct |
22 | Correct | 2 ms | 208 KB | Output is correct |
23 | Correct | 11 ms | 208 KB | Output is correct |
24 | Correct | 10 ms | 324 KB | Output is correct |
25 | Correct | 44 ms | 208 KB | Output is correct |
26 | Correct | 40 ms | 208 KB | Output is correct |
27 | Correct | 15 ms | 208 KB | Output is correct |
28 | Correct | 10 ms | 208 KB | Output is correct |
29 | Correct | 26 ms | 208 KB | Output is correct |
30 | Correct | 49 ms | 208 KB | Output is correct |
31 | Correct | 32 ms | 208 KB | Output is correct |
32 | Correct | 34 ms | 208 KB | Output is correct |
33 | Correct | 38 ms | 208 KB | Output is correct |
34 | Correct | 33 ms | 208 KB | Output is correct |
35 | Correct | 48 ms | 208 KB | Output is correct |
36 | Correct | 47 ms | 208 KB | Output is correct |
37 | Correct | 54 ms | 300 KB | Output is correct |
38 | Correct | 56 ms | 240 KB | Output is correct |
39 | Correct | 70 ms | 208 KB | Output is correct |
40 | Correct | 36 ms | 208 KB | Output is correct |
41 | Correct | 9 ms | 320 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 | 1 ms | 208 KB | Output is correct |
7 | Correct | 19 ms | 208 KB | Output is correct |
8 | Correct | 15 ms | 336 KB | Output is correct |
9 | Partially correct | 133 ms | 316 KB | Output is partially correct |
10 | Partially correct | 126 ms | 304 KB | Output is partially correct |
11 | Correct | 35 ms | 208 KB | Output is correct |
12 | Correct | 37 ms | 328 KB | Output is correct |
13 | Partially correct | 62 ms | 208 KB | Output is partially correct |
14 | Partially correct | 134 ms | 312 KB | Output is partially correct |
15 | Partially correct | 72 ms | 208 KB | Output is partially correct |
16 | Partially correct | 65 ms | 208 KB | Output is partially correct |
17 | Partially correct | 84 ms | 208 KB | Output is partially correct |
18 | Partially correct | 107 ms | 208 KB | Output is partially correct |
19 | Partially correct | 76 ms | 208 KB | Output is partially correct |
20 | Partially correct | 108 ms | 208 KB | Output is partially correct |
21 | Partially correct | 119 ms | 208 KB | Output is partially correct |
22 | Partially correct | 146 ms | 308 KB | Output is partially correct |
23 | Partially correct | 135 ms | 328 KB | Output is partially correct |
24 | Partially correct | 141 ms | 312 KB | Output is partially correct |
25 | Partially correct | 109 ms | 316 KB | Output is partially correct |
26 | Correct | 16 ms | 336 KB | Output is correct |
27 | Partially correct | 134 ms | 308 KB | Output is partially correct |
28 | Partially correct | 124 ms | 208 KB | Output is partially correct |
29 | Partially correct | 102 ms | 208 KB | Output is partially correct |
30 | Partially correct | 54 ms | 208 KB | Output is partially correct |
31 | Partially correct | 134 ms | 308 KB | Output is partially correct |
32 | Partially correct | 131 ms | 308 KB | Output is partially correct |
33 | Partially correct | 116 ms | 308 KB | Output is partially correct |
34 | Partially correct | 151 ms | 208 KB | Output is partially correct |
35 | Partially correct | 102 ms | 308 KB | Output is partially correct |
36 | Partially correct | 105 ms | 208 KB | Output is partially correct |
37 | Partially correct | 101 ms | 208 KB | Output is partially correct |
38 | Partially correct | 188 ms | 312 KB | Output is partially correct |
39 | Partially correct | 110 ms | 312 KB | Output is partially correct |
40 | Partially correct | 86 ms | 316 KB | Output is partially correct |
41 | Partially correct | 133 ms | 312 KB | Output is partially correct |
42 | Partially correct | 108 ms | 384 KB | Output is partially correct |
43 | Partially correct | 17 ms | 208 KB | Output is partially correct |
44 | Partially correct | 55 ms | 256 KB | Output is partially correct |
45 | Correct | 33 ms | 208 KB | Output is correct |
46 | Correct | 24 ms | 312 KB | Output is correct |
47 | Correct | 37 ms | 336 KB | Output is correct |
48 | Correct | 29 ms | 324 KB | Output is correct |