# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1078259 | 2024-08-27T14:36:44 Z | Faisal_Saqib | Rarest Insects (IOI22_insects) | C++17 | 1 ms | 344 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); } } 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(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 | 1 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 | Incorrect | 1 ms | 344 KB | Wrong answer. |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | Incorrect | 1 ms | 344 KB | Wrong answer. |
5 | Halted | 0 ms | 0 KB | - |
# | 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 | 1 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 344 KB | Output is correct |
5 | Incorrect | 0 ms | 344 KB | Wrong answer. |
6 | Halted | 0 ms | 0 KB | - |