# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
726147 | TheSahib | Rarest Insects (IOI22_insects) | C++17 | 1 ms | 272 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>
using namespace std;
int min_cardinality(int N) {
vector<int> types;
vector<int> left;
for (int i = 0; i < N; i++)
{
move_inside(i);
if(press_button() > 1){
left.push_back(i);
move_outside(i);
}
else{
types.push_back(i);
}
}
if(types.size() >= N / 2 + 1) return 1;
if(types.size() == 1) return N;
int l = 2, r = N / types.size();
int leftOutN = 0;
while(l < r){
vector<int> tmp;
int mid = (l + r) / 2;
int cnt = 0;
for(int a:left){
move_inside(a);
if(cnt--) continue;
int c = press_button();
if(c > mid){
move_outside(a);
tmp.push_back(a);
--c;
}
}
if(N - tmp.size() - leftOutN == mid * types.size()){
l = mid;
left = tmp;
}
else{
r = mid - 1;
vector<int> tmp1;
for(int a:left){
if(find(tmp.begin(), tmp.end(), a) == tmp.end()){
move_outside(a);
tmp1.push_back(a);
}
else{
++leftOutN;
}
}
left = tmp1;
}
}
return l;
}
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... |