# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
830527 | 2023-08-19T07:42:59 Z | FatihSolak | Rarest Insects (IOI22_insects) | C++17 | 0 ms | 208 KB |
#include "insects.h" #include <bits/stdc++.h> using namespace std; int min_cardinality(int N){ vector<int> v; int now = 0; int dif = 0; auto add = [&](int x){ v.push_back(x); move_inside(x); now = press_button(); }; auto del = [&](){ move_outside(v.back()); v.pop_back(); now = press_button(); }; add(1); dif = 1; for(int i = 1;i<N;i++){ add(i); if(now == 2){ del(); } else dif++; } int last = 1; int l = 1,r = N/dif; while(l < r){ int m = (l + r + 1)/2; if(last < m){ for(int i = 0;i<N;i++){ if(find(v.begin(),v.end(),i) == v.end()){ add(i); if(now > m) del(); } } } if(last > m){ vector<int> tmp; while(now != m){ tmp.push_back(v.back()); del(); } for(int i = 0;i<N;i++){ if(find(tmp.begin(),tmp.end(),i) == tmp.end() && find(v.begin(),v.end(),i) == v.end()){ add(i); if(now > m) del(); } } } last = m; if(v.size() == m * dif){ l = m; } else r = m -1; } return l; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 208 KB | Wrong answer. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 208 KB | Wrong answer. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Incorrect | 0 ms | 208 KB | Wrong answer. |
3 | Halted | 0 ms | 0 KB | - |