# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1078313 | 2024-08-27T15:10:45 Z | Faisal_Saqib | Rarest Insects (IOI22_insects) | C++17 | 759 ms | 21616 KB |
#include <bits/stdc++.h> using namespace std; void move_inside(int i); void move_outside(int i); int press_button(); set<int> machine,rem,real_; void add(int x) { if(machine.find(x)==machine.end()) { machine.insert(x); } } void remp(int x) { if(machine.find(x)!=machine.end()) { machine.erase(x); } } map<vector<int>,int> store; int ask() { vector<int> cur(begin(machine),end(machine)); if(store.find(cur)!=store.end()) return store[cur]; for(auto&i:real_) if(machine.find(i)==machine.end()) move_outside(i); for(auto&i:machine) if(real_.find(i)==real_.end()) move_inside(i); real_=machine; return store[cur]=press_button(); } int min_cardinality(int n) { add(0); for(int i=1;i<n;i++) { add(i); if(ask()>1) { rem.insert(i); remp(i); } } int sz=machine.size(); int s=1; int e=(n/sz)+1; while(s+1<e) { int mid=(s+e)/2; vector<int> cur; for(auto&i:rem) { if(machine.size()==(sz*mid)) break; add(i); if(machine.size()>mid and ask()>mid) { remp(i); } else { cur.push_back(i); if(machine.size()==(sz*mid)) break; } } if(machine.size()==((sz*mid))) { s=mid; for(auto&i:cur) rem.erase(i); } else{ int szp=machine.size(); e=min(mid,1+(szp/sz)); rem.clear(); for(auto&i:cur) { rem.insert(i); remp(i); } } } return s; }
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 | 1 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 | 3 ms | 344 KB | Output is correct |
8 | Correct | 5 ms | 512 KB | Output is correct |
9 | Correct | 4 ms | 600 KB | Output is correct |
10 | Correct | 4 ms | 344 KB | Output is correct |
11 | Correct | 2 ms | 344 KB | Output is correct |
12 | Correct | 4 ms | 344 KB | Output is correct |
13 | Correct | 4 ms | 468 KB | Output is correct |
14 | Correct | 5 ms | 760 KB | Output is correct |
15 | Correct | 5 ms | 600 KB | Output is correct |
16 | Correct | 6 ms | 600 KB | Output is correct |
17 | Correct | 6 ms | 484 KB | Output is correct |
18 | Correct | 4 ms | 344 KB | Output is correct |
19 | Correct | 4 ms | 600 KB | Output is correct |
20 | Correct | 4 ms | 568 KB | Output is correct |
21 | Correct | 3 ms | 344 KB | Output is correct |
22 | Correct | 3 ms | 344 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 | 1 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 | 3 ms | 344 KB | Output is correct |
8 | Correct | 5 ms | 512 KB | Output is correct |
9 | Correct | 4 ms | 600 KB | Output is correct |
10 | Correct | 4 ms | 344 KB | Output is correct |
11 | Correct | 2 ms | 344 KB | Output is correct |
12 | Correct | 4 ms | 344 KB | Output is correct |
13 | Correct | 4 ms | 468 KB | Output is correct |
14 | Correct | 5 ms | 760 KB | Output is correct |
15 | Correct | 5 ms | 600 KB | Output is correct |
16 | Correct | 6 ms | 600 KB | Output is correct |
17 | Correct | 6 ms | 484 KB | Output is correct |
18 | Correct | 4 ms | 344 KB | Output is correct |
19 | Correct | 4 ms | 600 KB | Output is correct |
20 | Correct | 4 ms | 568 KB | Output is correct |
21 | Correct | 3 ms | 344 KB | Output is correct |
22 | Correct | 3 ms | 344 KB | Output is correct |
23 | Correct | 5 ms | 456 KB | Output is correct |
24 | Correct | 49 ms | 3004 KB | Output is correct |
25 | Correct | 95 ms | 4100 KB | Output is correct |
26 | Correct | 86 ms | 4176 KB | Output is correct |
27 | Correct | 37 ms | 1476 KB | Output is correct |
28 | Correct | 31 ms | 1616 KB | Output is correct |
29 | Correct | 61 ms | 2640 KB | Output is correct |
30 | Correct | 53 ms | 2792 KB | Output is correct |
31 | Correct | 74 ms | 3780 KB | Output is correct |
32 | Correct | 73 ms | 3920 KB | Output is correct |
33 | Correct | 84 ms | 4436 KB | Output is correct |
34 | Correct | 95 ms | 4052 KB | Output is correct |
35 | Correct | 76 ms | 3912 KB | Output is correct |
36 | Correct | 92 ms | 3868 KB | Output is correct |
37 | Correct | 82 ms | 4192 KB | Output is correct |
38 | Correct | 61 ms | 3212 KB | Output is correct |
39 | Correct | 58 ms | 2956 KB | Output is correct |
40 | Correct | 55 ms | 3152 KB | Output is correct |
41 | Correct | 30 ms | 1872 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 | 1 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 | 14 ms | 716 KB | Output is correct |
8 | Correct | 269 ms | 10108 KB | Output is correct |
9 | Correct | 510 ms | 15484 KB | Output is correct |
10 | Correct | 467 ms | 15304 KB | Output is correct |
11 | Correct | 77 ms | 4308 KB | Output is correct |
12 | Correct | 167 ms | 8820 KB | Output is correct |
13 | Correct | 151 ms | 6736 KB | Output is correct |
14 | Correct | 235 ms | 8852 KB | Output is correct |
15 | Correct | 385 ms | 12908 KB | Output is correct |
16 | Correct | 425 ms | 13776 KB | Output is correct |
17 | Correct | 457 ms | 14016 KB | Output is correct |
18 | Correct | 482 ms | 15188 KB | Output is correct |
19 | Correct | 481 ms | 15400 KB | Output is correct |
20 | Correct | 515 ms | 15604 KB | Output is correct |
21 | Correct | 495 ms | 15340 KB | Output is correct |
22 | Correct | 363 ms | 13048 KB | Output is correct |
23 | Correct | 219 ms | 9592 KB | Output is correct |
24 | Correct | 401 ms | 12928 KB | Output is correct |
25 | Correct | 336 ms | 11516 KB | Output is correct |
26 | Correct | 156 ms | 6932 KB | Output is correct |
27 | Correct | 636 ms | 19576 KB | Output is correct |
28 | Correct | 280 ms | 10064 KB | Output is correct |
29 | Correct | 732 ms | 20908 KB | Output is correct |
30 | Correct | 759 ms | 20624 KB | Output is correct |
31 | Correct | 435 ms | 14928 KB | Output is correct |
32 | Correct | 452 ms | 15984 KB | Output is correct |
33 | Correct | 218 ms | 9536 KB | Output is correct |
34 | Correct | 204 ms | 9588 KB | Output is correct |
35 | Partially correct | 686 ms | 20992 KB | Output is partially correct |
36 | Correct | 516 ms | 16768 KB | Output is correct |
37 | Correct | 458 ms | 14812 KB | Output is correct |
38 | Correct | 438 ms | 14556 KB | Output is correct |
39 | Correct | 573 ms | 19464 KB | Output is correct |
40 | Correct | 268 ms | 10480 KB | Output is correct |
41 | Correct | 543 ms | 16720 KB | Output is correct |
42 | Partially correct | 688 ms | 21616 KB | Output is partially correct |
43 | Correct | 10 ms | 600 KB | Output is correct |
44 | Correct | 60 ms | 2652 KB | Output is correct |
45 | Correct | 256 ms | 10388 KB | Output is correct |
46 | Correct | 107 ms | 6996 KB | Output is correct |
47 | Correct | 258 ms | 10632 KB | Output is correct |
48 | Correct | 172 ms | 8896 KB | Output is correct |