# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
629052 | jhhope1 | Rarest Insects (IOI22_insects) | C++17 | 86 ms | 324 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "insects.h"
using namespace std;
typedef long long ll;
int g;
int f(int h, int H, vector<int> V){
if(H == h) return h;
vector<int> O, I;
for(int x: V){
move_inside(x);
if(press_button() == (h + H + 1) / 2 + 1){
move_outside(x);
O.push_back(x);
}
else{
I.push_back(x);
}
}
if(((H + h + 1) / 2 - h) * g == I.size()){
return f((h + H + 1)/2, H, O);
}
for(int x: I){
move_outside(x);
}
return f(h, (h + H + 1)/2 - 1, I);
}
int min_cardinality(int N) {
move_inside(0);
vector<int> V;
for(int i=0 ; i<N ; i++){
move_inside(i);
if(press_button() == 2){
move_outside(i);
V.push_back(i);
}
}
g = N - V.size();
vector<int> W;
for(int x: V){
move_inside(x);
if(press_button() > N/g){
move_outside(x);
N--;
}
else{
W.push_back(x);
}
}
for(int x: W){
move_outside(x);
}
return f(1, N/g, W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |