# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
630045 | _Avocado_ | Rarest Insects (IOI22_insects) | C++17 | 80 ms | 444 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>unique(n);
int unique_cnt = 0;
for(int i = 0; i<n; ++i){
move_inside(i);
int q = press_button();
if(q == 1){
unique[i] = 1;
++unique_cnt;
}
else move_outside(i);
}
int r = n/unique_cnt+1;
int l = 0;
vector<int>cur;
set<int>in_box;
for(int i = 0; i<n; ++i){
if(!unique[i]) cur.push_back(i);
else in_box.insert(i);
}
while(r-l > 1){
int m = (r+l)/2;
//cout<<"m "<<m<<endl;
vector<int>high, low;
for(int i = 0; i<cur.size(); ++i){
move_inside(cur[i]);
int q = press_button();
if(q > m){
high.push_back(cur[i]);
move_outside(cur[i]);
}
else{
low.push_back(cur[i]);
in_box.insert(cur[i]);
}
}
if(in_box.size() != m*unique_cnt){
for(int i = 0; i<cur.size(); ++i){
move_outside(cur[i]);
in_box.erase(cur[i]);
}
cur = low;
r = m;
}
else{
cur = high;
l = m;
}
}
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... |