# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
632182 | beaconmc | Rarest Insects (IOI22_insects) | C++17 | 72 ms | 436 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 "insects.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
int min_cardinality(int N) {
vector<ll> ins;
vector<ll> outs;
FOR(i,0,N){
move_inside(i);
ll sus = press_button();
if (sus>1){
move_outside(i);
outs.push_back(i);
}else{
ins.push_back(i);
}
}
ll numsize = ins.size();
ll lo = 1;
ll hi = N/ins.size()+1;
while (lo<hi){
int mid = lo + (hi - lo + 1) / 2;
vector<ll> nowin;
vector<ll> nowout;
while (outs.size()){
ll sus = outs[outs.size()-1];
outs.pop_back();
move_inside(sus);
ll count = press_button();
if (count>mid){
move_outside(sus);
nowout.push_back(sus);
}else{
nowin.push_back(sus);
}
if (ins.size() + nowin.size() == mid*numsize){
break;
}
}
if (ins.size() + nowin.size() == mid*numsize){
for (auto&i : nowin){
ins.push_back(i);
}
for (auto&i : nowout){
outs.push_back(i);
}
lo = mid;
}else{
for (auto&i : nowin){
move_outside(i);
outs.push_back(i);
}
hi = mid-1;
}
}
return lo;
}
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... |