# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1058150 | 2024-08-14T08:43:34 Z | hirayuu_oj | Rarest Insects (IOI22_insects) | C++17 | 77 ms | 1008 KB |
#include "insects.h" #include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define rng(i,l,r) for(int i=(l); i<(r); i++) #define all(x) x.begin(),x.end() using ll=long long; int min_cardinality(int N) { vector<int> types; vector<bool> mark(N,false); rep(i,N) { move_inside(i); if(press_button()==1) { mark[i]=true; types.emplace_back(i); } else move_outside(i); } if(types.size()==1)return N; vector<int> cnt(types.size(),1); vector<vector<array<int,3>>> ser(types.size()+1); rep(i,N) { if(!mark[i])ser[types.size()/2].push_back({i,(int)types.size(),0}); } int rest=N-types.size(); int pos=types.size(); while(rest) { for(auto data:ser[pos]) { int mid=pos; int ok=data[1]; int ng=data[2]; move_inside(data[0]); if(press_button()==2) { ok=mid; } else { ng=mid; } move_outside(data[0]); if(abs(ok-ng)==1) { cnt[ok-1]++; rest--; } else { ser[(ok+ng)/2].push_back({data[0],ok,ng}); } } ser[pos].clear(); pair<int,int> near={998244353,-1}; rep(i,types.size()+1) { if(ser[i].size())near=min(near,{abs(pos-i),i}); } if(near.second<pos) { pos--; move_outside(types[pos]); } else { move_inside(types[pos]); pos++; } } int ans=998244353; for(int i:cnt)ans=min(ans,i); return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 344 KB | Output is correct |
7 | Correct | 2 ms | 436 KB | Output is correct |
8 | Correct | 3 ms | 344 KB | Output is correct |
9 | Correct | 5 ms | 608 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
11 | Correct | 3 ms | 344 KB | Output is correct |
12 | Correct | 3 ms | 600 KB | Output is correct |
13 | Correct | 4 ms | 344 KB | Output is correct |
14 | Correct | 3 ms | 344 KB | Output is correct |
15 | Correct | 2 ms | 436 KB | Output is correct |
16 | Correct | 3 ms | 444 KB | Output is correct |
17 | Correct | 3 ms | 436 KB | Output is correct |
18 | Correct | 2 ms | 344 KB | Output is correct |
19 | Correct | 2 ms | 600 KB | Output is correct |
20 | Correct | 4 ms | 344 KB | Output is correct |
21 | Correct | 4 ms | 344 KB | Output is correct |
22 | Correct | 4 ms | 444 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 344 KB | Output is correct |
7 | Correct | 2 ms | 436 KB | Output is correct |
8 | Correct | 3 ms | 344 KB | Output is correct |
9 | Correct | 5 ms | 608 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
11 | Correct | 3 ms | 344 KB | Output is correct |
12 | Correct | 3 ms | 600 KB | Output is correct |
13 | Correct | 4 ms | 344 KB | Output is correct |
14 | Correct | 3 ms | 344 KB | Output is correct |
15 | Correct | 2 ms | 436 KB | Output is correct |
16 | Correct | 3 ms | 444 KB | Output is correct |
17 | Correct | 3 ms | 436 KB | Output is correct |
18 | Correct | 2 ms | 344 KB | Output is correct |
19 | Correct | 2 ms | 600 KB | Output is correct |
20 | Correct | 4 ms | 344 KB | Output is correct |
21 | Correct | 4 ms | 344 KB | Output is correct |
22 | Correct | 4 ms | 444 KB | Output is correct |
23 | Correct | 4 ms | 344 KB | Output is correct |
24 | Correct | 4 ms | 344 KB | Output is correct |
25 | Correct | 20 ms | 464 KB | Output is correct |
26 | Correct | 24 ms | 460 KB | Output is correct |
27 | Correct | 9 ms | 600 KB | Output is correct |
28 | Correct | 19 ms | 736 KB | Output is correct |
29 | Correct | 17 ms | 444 KB | Output is correct |
30 | Correct | 51 ms | 600 KB | Output is correct |
31 | Correct | 13 ms | 948 KB | Output is correct |
32 | Correct | 15 ms | 600 KB | Output is correct |
33 | Correct | 21 ms | 456 KB | Output is correct |
34 | Correct | 16 ms | 588 KB | Output is correct |
35 | Correct | 25 ms | 600 KB | Output is correct |
36 | Correct | 12 ms | 728 KB | Output is correct |
37 | Correct | 32 ms | 600 KB | Output is correct |
38 | Correct | 25 ms | 692 KB | Output is correct |
39 | Correct | 34 ms | 724 KB | Output is correct |
40 | Correct | 26 ms | 600 KB | Output is correct |
41 | Correct | 25 ms | 464 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 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 | 1 ms | 344 KB | Output is correct |
7 | Correct | 7 ms | 344 KB | Output is correct |
8 | Correct | 9 ms | 452 KB | Output is correct |
9 | Partially correct | 71 ms | 576 KB | Output is partially correct |
10 | Partially correct | 65 ms | 804 KB | Output is partially correct |
11 | Correct | 21 ms | 436 KB | Output is correct |
12 | Partially correct | 47 ms | 780 KB | Output is partially correct |
13 | Partially correct | 28 ms | 712 KB | Output is partially correct |
14 | Partially correct | 50 ms | 592 KB | Output is partially correct |
15 | Partially correct | 28 ms | 496 KB | Output is partially correct |
16 | Partially correct | 31 ms | 484 KB | Output is partially correct |
17 | Partially correct | 41 ms | 712 KB | Output is partially correct |
18 | Partially correct | 40 ms | 592 KB | Output is partially correct |
19 | Partially correct | 35 ms | 652 KB | Output is partially correct |
20 | Partially correct | 51 ms | 728 KB | Output is partially correct |
21 | Partially correct | 61 ms | 1004 KB | Output is partially correct |
22 | Partially correct | 48 ms | 792 KB | Output is partially correct |
23 | Partially correct | 75 ms | 832 KB | Output is partially correct |
24 | Partially correct | 70 ms | 708 KB | Output is partially correct |
25 | Partially correct | 51 ms | 764 KB | Output is partially correct |
26 | Partially correct | 59 ms | 672 KB | Output is partially correct |
27 | Partially correct | 63 ms | 800 KB | Output is partially correct |
28 | Partially correct | 74 ms | 760 KB | Output is partially correct |
29 | Partially correct | 55 ms | 464 KB | Output is partially correct |
30 | Partially correct | 45 ms | 736 KB | Output is partially correct |
31 | Partially correct | 68 ms | 920 KB | Output is partially correct |
32 | Partially correct | 76 ms | 592 KB | Output is partially correct |
33 | Partially correct | 76 ms | 592 KB | Output is partially correct |
34 | Partially correct | 76 ms | 572 KB | Output is partially correct |
35 | Partially correct | 63 ms | 592 KB | Output is partially correct |
36 | Partially correct | 75 ms | 668 KB | Output is partially correct |
37 | Partially correct | 61 ms | 540 KB | Output is partially correct |
38 | Partially correct | 69 ms | 672 KB | Output is partially correct |
39 | Partially correct | 57 ms | 1008 KB | Output is partially correct |
40 | Partially correct | 72 ms | 812 KB | Output is partially correct |
41 | Partially correct | 76 ms | 744 KB | Output is partially correct |
42 | Partially correct | 77 ms | 720 KB | Output is partially correct |
43 | Partially correct | 7 ms | 344 KB | Output is partially correct |
44 | Partially correct | 27 ms | 592 KB | Output is partially correct |
45 | Correct | 10 ms | 344 KB | Output is correct |
46 | Partially correct | 58 ms | 848 KB | Output is partially correct |
47 | Partially correct | 45 ms | 800 KB | Output is partially correct |
48 | Partially correct | 43 ms | 764 KB | Output is partially correct |