#include "insects.h"
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using ll = long long;
using namespace std;
template<typename T>
using matrix = vector<vector<T>>;
struct Machine {
set<int> s;
void insert(int id){
s.insert(id);
move_inside(id);
}
void erase(int id){
s.erase(id);
move_outside(id);
}
int resp(){
return press_button();
}
void clear(){
auto it = s.begin();
while(it!=s.end()){
move_outside(*it);
it = s.erase(it);
}
}
};
int min_cardinality(int N) {
vector<int> dif;
vector<int> resto;
Machine m;
for(int i = 0; i < N; i++){
m.insert(i);
if(m.resp() == 1){
dif.push_back(i);
} else m.erase(i), resto.push_back(i);
}
m.clear();
int ini = 1, fim = N/dif.size();
auto putless =[&](int mx){
for(int i : resto){
m.insert(i);
if(m.resp() > mx)
m.erase(i);
}
};
while(ini!=fim){
int mid = (ini+fim+1)>>1;
putless(mid-1);
bool ok = 1;
for(int i : dif){
m.insert(i);
ok&= m.resp() == i;
}
if(ok)
ini = mid;
else fim = mid-1;
m.clear();
}
return ini;
}
# |
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 |
- |