# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1057911 | 2024-08-14T07:17:08 Z | tolbi | Rarest Insects (IOI22_insects) | C++17 | 88 ms | 968 KB |
#include "insects.h" #include <bits/stdc++.h> using namespace std; /* void move_inside(int i); void move_outside(int i); int press_button(); */ int mid(pair<int,int> &pr){ return (pr.first+pr.second)/2; } int min_cardinality(int N) { vector<int> unik; vector<pair<int,int>> dec(N,{-1,-1}); vector<int> ans(N,-1); for (int i = 0; i < N; i++){ move_inside(i); if (press_button()>1){ move_outside(i); dec[i]={0,23}; } else { ans[i]=unik.size(); unik.push_back(i); } } vector<vector<int>> pbs(unik.size()); for (int i = 0; i < N; ++i) { if (dec[i].first!=-1) { dec[i].second=unik.size()-1; pbs[mid(dec[i])].push_back(i); } } int kalan = N-unik.size(); int turn = 0; while (kalan>0){ if (turn==0){ for (int i = (int)unik.size()-1; i >= 0; i--){ while (pbs[i].size()){ int node = pbs[i].back(); pbs[i].pop_back(); move_inside(node); if (press_button()>1){ dec[node].second=i; } else { dec[node].first=i+1; } move_outside(node); } move_outside(unik[i]); } } else { for (int i = 0; i < unik.size(); i++){ move_inside(unik[i]); while (pbs[i].size()){ int node = pbs[i].back(); pbs[i].pop_back(); move_inside(node); if (press_button()>1){ dec[node].second=i; } else { dec[node].first=i+1; } move_outside(node); } } } turn=1-turn; for (int i = 0; i < N; i++){ if (ans[i]==-1){ if (dec[i].first==dec[i].second){ ans[i]=dec[i].first; kalan--; } else { pbs[mid(dec[i])].push_back(i); } } } } map<int,int> mp; for (int i = 0; i < N; ++i) { mp[ans[i]]++; } int ns = N; for (auto it : mp){ ns = min(ns,it.second); } return ns; }
Compilation message
# | Verdict | Execution time | Memory | 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 | 2 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 2 ms | 436 KB | Output is correct |
9 | Correct | 2 ms | 344 KB | Output is correct |
10 | Correct | 2 ms | 344 KB | Output is correct |
11 | Correct | 5 ms | 436 KB | Output is correct |
12 | Correct | 2 ms | 600 KB | Output is correct |
13 | Correct | 5 ms | 436 KB | Output is correct |
14 | Correct | 2 ms | 344 KB | Output is correct |
15 | Correct | 3 ms | 440 KB | Output is correct |
16 | Correct | 5 ms | 344 KB | Output is correct |
17 | Correct | 3 ms | 344 KB | Output is correct |
18 | Correct | 3 ms | 344 KB | Output is correct |
19 | Correct | 3 ms | 344 KB | Output is correct |
20 | Correct | 3 ms | 444 KB | Output is correct |
21 | Correct | 5 ms | 344 KB | Output is correct |
22 | Correct | 3 ms | 444 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 | 2 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 2 ms | 436 KB | Output is correct |
9 | Correct | 2 ms | 344 KB | Output is correct |
10 | Correct | 2 ms | 344 KB | Output is correct |
11 | Correct | 5 ms | 436 KB | Output is correct |
12 | Correct | 2 ms | 600 KB | Output is correct |
13 | Correct | 5 ms | 436 KB | Output is correct |
14 | Correct | 2 ms | 344 KB | Output is correct |
15 | Correct | 3 ms | 440 KB | Output is correct |
16 | Correct | 5 ms | 344 KB | Output is correct |
17 | Correct | 3 ms | 344 KB | Output is correct |
18 | Correct | 3 ms | 344 KB | Output is correct |
19 | Correct | 3 ms | 344 KB | Output is correct |
20 | Correct | 3 ms | 444 KB | Output is correct |
21 | Correct | 5 ms | 344 KB | Output is correct |
22 | Correct | 3 ms | 444 KB | Output is correct |
23 | Correct | 8 ms | 444 KB | Output is correct |
24 | Correct | 4 ms | 448 KB | Output is correct |
25 | Correct | 19 ms | 444 KB | Output is correct |
26 | Correct | 32 ms | 592 KB | Output is correct |
27 | Correct | 11 ms | 344 KB | Output is correct |
28 | Correct | 18 ms | 712 KB | Output is correct |
29 | Correct | 12 ms | 344 KB | Output is correct |
30 | Correct | 22 ms | 460 KB | Output is correct |
31 | Correct | 16 ms | 448 KB | Output is correct |
32 | Correct | 21 ms | 600 KB | Output is correct |
33 | Correct | 20 ms | 444 KB | Output is correct |
34 | Correct | 20 ms | 444 KB | Output is correct |
35 | Correct | 17 ms | 448 KB | Output is correct |
36 | Correct | 21 ms | 592 KB | Output is correct |
37 | Correct | 30 ms | 696 KB | Output is correct |
38 | Correct | 36 ms | 444 KB | Output is correct |
39 | Correct | 29 ms | 704 KB | Output is correct |
40 | Correct | 28 ms | 712 KB | Output is correct |
41 | Correct | 23 ms | 460 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 | 16 ms | 460 KB | Output is correct |
8 | Correct | 8 ms | 600 KB | Output is correct |
9 | Partially correct | 58 ms | 460 KB | Output is partially correct |
10 | Partially correct | 71 ms | 632 KB | Output is partially correct |
11 | Correct | 14 ms | 456 KB | Output is correct |
12 | Partially correct | 57 ms | 936 KB | Output is partially correct |
13 | Partially correct | 20 ms | 460 KB | Output is partially correct |
14 | Partially correct | 58 ms | 596 KB | Output is partially correct |
15 | Partially correct | 18 ms | 468 KB | Output is partially correct |
16 | Partially correct | 45 ms | 600 KB | Output is partially correct |
17 | Partially correct | 40 ms | 452 KB | Output is partially correct |
18 | Partially correct | 52 ms | 452 KB | Output is partially correct |
19 | Partially correct | 48 ms | 472 KB | Output is partially correct |
20 | Partially correct | 50 ms | 600 KB | Output is partially correct |
21 | Partially correct | 44 ms | 744 KB | Output is partially correct |
22 | Partially correct | 62 ms | 488 KB | Output is partially correct |
23 | Partially correct | 85 ms | 716 KB | Output is partially correct |
24 | Partially correct | 88 ms | 752 KB | Output is partially correct |
25 | Partially correct | 54 ms | 784 KB | Output is partially correct |
26 | Partially correct | 33 ms | 704 KB | Output is partially correct |
27 | Partially correct | 57 ms | 592 KB | Output is partially correct |
28 | Partially correct | 64 ms | 460 KB | Output is partially correct |
29 | Partially correct | 47 ms | 592 KB | Output is partially correct |
30 | Partially correct | 39 ms | 492 KB | Output is partially correct |
31 | Partially correct | 50 ms | 968 KB | Output is partially correct |
32 | Partially correct | 72 ms | 344 KB | Output is partially correct |
33 | Partially correct | 77 ms | 592 KB | Output is partially correct |
34 | Partially correct | 88 ms | 740 KB | Output is partially correct |
35 | Partially correct | 67 ms | 960 KB | Output is partially correct |
36 | Partially correct | 58 ms | 496 KB | Output is partially correct |
37 | Partially correct | 56 ms | 492 KB | Output is partially correct |
38 | Partially correct | 47 ms | 500 KB | Output is partially correct |
39 | Partially correct | 56 ms | 736 KB | Output is partially correct |
40 | Partially correct | 74 ms | 728 KB | Output is partially correct |
41 | Partially correct | 65 ms | 488 KB | Output is partially correct |
42 | Partially correct | 59 ms | 600 KB | Output is partially correct |
43 | Partially correct | 11 ms | 344 KB | Output is partially correct |
44 | Partially correct | 30 ms | 712 KB | Output is partially correct |
45 | Correct | 17 ms | 456 KB | Output is correct |
46 | Partially correct | 49 ms | 620 KB | Output is partially correct |
47 | Partially correct | 49 ms | 588 KB | Output is partially correct |
48 | Partially correct | 69 ms | 724 KB | Output is partially correct |