# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1078253 | 2024-08-27T14:33:33 Z | Faisal_Saqib | Rarest Insects (IOI22_insects) | C++17 | 796 ms | 21504 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_; int sm=0; void add(int x) { if(machine.find(x)==machine.end()) { // move_inside(x); machine.insert(x); } } void remp(int x) { if(machine.find(x)!=machine.end()) { // move_outside(x); machine.erase(x); } } map<vector<int>,int> store; int ask() { 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; vector<int> cur(begin(machine),end(machine)); if(store.find(cur)==store.end()) store[cur]=press_button(); // cout<<"Query for: "; // for(auto j:cur) // { // cout<<j<<' '; // } // cout<<" ans: "<<store[cur]<<endl; return store[cur]; } 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; // cout<<endl; // cout<<"for "<<mid<<endl; // cout<<"\nMachine: "; // for(auto j:machine) // { // cout<<j<<' '; // } // cout<<endl; for(auto&i:rem) { if(machine.size()==(sz*mid)) break; // cout<<"Add and query "<<i<<endl; add(i); if(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{ e=mid; 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 | 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 | 1 ms | 344 KB | Output is correct |
6 | Correct | 5 ms | 344 KB | Output is correct |
7 | Correct | 3 ms | 344 KB | Output is correct |
8 | Correct | 5 ms | 600 KB | Output is correct |
9 | Correct | 5 ms | 600 KB | Output is correct |
10 | Correct | 4 ms | 600 KB | Output is correct |
11 | Correct | 2 ms | 456 KB | Output is correct |
12 | Correct | 5 ms | 516 KB | Output is correct |
13 | Correct | 6 ms | 600 KB | Output is correct |
14 | Correct | 7 ms | 576 KB | Output is correct |
15 | Correct | 8 ms | 600 KB | Output is correct |
16 | Correct | 5 ms | 564 KB | Output is correct |
17 | Correct | 6 ms | 808 KB | Output is correct |
18 | Correct | 5 ms | 344 KB | Output is correct |
19 | Correct | 4 ms | 444 KB | Output is correct |
20 | Correct | 5 ms | 468 KB | Output is correct |
21 | Correct | 4 ms | 344 KB | Output is correct |
22 | Correct | 2 ms | 600 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 | 1 ms | 344 KB | Output is correct |
6 | Correct | 5 ms | 344 KB | Output is correct |
7 | Correct | 3 ms | 344 KB | Output is correct |
8 | Correct | 5 ms | 600 KB | Output is correct |
9 | Correct | 5 ms | 600 KB | Output is correct |
10 | Correct | 4 ms | 600 KB | Output is correct |
11 | Correct | 2 ms | 456 KB | Output is correct |
12 | Correct | 5 ms | 516 KB | Output is correct |
13 | Correct | 6 ms | 600 KB | Output is correct |
14 | Correct | 7 ms | 576 KB | Output is correct |
15 | Correct | 8 ms | 600 KB | Output is correct |
16 | Correct | 5 ms | 564 KB | Output is correct |
17 | Correct | 6 ms | 808 KB | Output is correct |
18 | Correct | 5 ms | 344 KB | Output is correct |
19 | Correct | 4 ms | 444 KB | Output is correct |
20 | Correct | 5 ms | 468 KB | Output is correct |
21 | Correct | 4 ms | 344 KB | Output is correct |
22 | Correct | 2 ms | 600 KB | Output is correct |
23 | Correct | 49 ms | 2900 KB | Output is correct |
24 | Correct | 56 ms | 3164 KB | Output is correct |
25 | Correct | 113 ms | 3888 KB | Output is correct |
26 | Correct | 100 ms | 4044 KB | Output is correct |
27 | Correct | 33 ms | 1844 KB | Output is correct |
28 | Correct | 33 ms | 1372 KB | Output is correct |
29 | Correct | 48 ms | 2128 KB | Output is correct |
30 | Correct | 79 ms | 2732 KB | Output is correct |
31 | Correct | 86 ms | 3672 KB | Output is correct |
32 | Correct | 85 ms | 3920 KB | Output is correct |
33 | Correct | 118 ms | 4524 KB | Output is correct |
34 | Correct | 134 ms | 4320 KB | Output is correct |
35 | Correct | 81 ms | 4016 KB | Output is correct |
36 | Correct | 87 ms | 3828 KB | Output is correct |
37 | Correct | 94 ms | 4184 KB | Output is correct |
38 | Correct | 64 ms | 2896 KB | Output is correct |
39 | Correct | 78 ms | 3036 KB | Output is correct |
40 | Correct | 60 ms | 3068 KB | Output is correct |
41 | Correct | 37 ms | 2004 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 | 0 ms | 344 KB | Output is correct |
7 | Correct | 278 ms | 10588 KB | Output is correct |
8 | Correct | 283 ms | 10264 KB | Output is correct |
9 | Correct | 534 ms | 15552 KB | Output is correct |
10 | Correct | 450 ms | 15300 KB | Output is correct |
11 | Correct | 120 ms | 5224 KB | Output is correct |
12 | Correct | 179 ms | 8740 KB | Output is correct |
13 | Correct | 205 ms | 7000 KB | Output is correct |
14 | Correct | 233 ms | 8780 KB | Output is correct |
15 | Correct | 450 ms | 13208 KB | Output is correct |
16 | Correct | 465 ms | 13952 KB | Output is correct |
17 | Correct | 517 ms | 14064 KB | Output is correct |
18 | Correct | 525 ms | 15180 KB | Output is correct |
19 | Correct | 537 ms | 15388 KB | Output is correct |
20 | Correct | 575 ms | 15476 KB | Output is correct |
21 | Correct | 487 ms | 15200 KB | Output is correct |
22 | Correct | 354 ms | 13472 KB | Output is correct |
23 | Correct | 259 ms | 9648 KB | Output is correct |
24 | Correct | 358 ms | 12964 KB | Output is correct |
25 | Correct | 322 ms | 11472 KB | Output is correct |
26 | Correct | 183 ms | 6956 KB | Output is correct |
27 | Correct | 704 ms | 19484 KB | Output is correct |
28 | Correct | 282 ms | 10412 KB | Output is correct |
29 | Correct | 700 ms | 20864 KB | Output is correct |
30 | Correct | 796 ms | 20836 KB | Output is correct |
31 | Correct | 570 ms | 14892 KB | Output is correct |
32 | Correct | 552 ms | 16048 KB | Output is correct |
33 | Correct | 245 ms | 9120 KB | Output is correct |
34 | Correct | 257 ms | 9220 KB | Output is correct |
35 | Partially correct | 762 ms | 20932 KB | Output is partially correct |
36 | Correct | 629 ms | 16464 KB | Output is correct |
37 | Correct | 520 ms | 14676 KB | Output is correct |
38 | Correct | 508 ms | 14596 KB | Output is correct |
39 | Correct | 708 ms | 19216 KB | Output is correct |
40 | Correct | 279 ms | 10176 KB | Output is correct |
41 | Correct | 605 ms | 16768 KB | Output is correct |
42 | Partially correct | 763 ms | 21504 KB | Output is partially correct |
43 | Correct | 12 ms | 600 KB | Output is correct |
44 | Correct | 85 ms | 3296 KB | Output is correct |
45 | Correct | 357 ms | 10740 KB | Output is correct |
46 | Correct | 169 ms | 6968 KB | Output is correct |
47 | Correct | 301 ms | 10576 KB | Output is correct |
48 | Correct | 220 ms | 8684 KB | Output is correct |