# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1078247 | Faisal_Saqib | Rarest Insects (IOI22_insects) | C++17 | 49 ms | 980 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>
using namespace std;
void move_inside(int i);
void move_outside(int i);
int press_button();
int min_cardinality(int n)
{
set<int> machine,rem;
machine.insert(0);
move_inside(0);
for(int i=1;i<n;i++)
{
move_inside(i);
if(press_button()==1)
{
machine.insert(i);
}
else
{
rem.insert(i);
move_outside(i);
}
}
int sz=machine.size();
int s=1;
int e=(n/sz)+1;
while(s+1<e)
{
int mid=(s+e)/2;
vector<int> cur;
for(auto i:rem)
{
if(machine.size()==(sz*mid))
break;
move_inside(i);
if(press_button()>mid)
{
move_outside(i);
}
else
{
cur.push_back(i);
machine.insert(i);
if(machine.size()==(sz*mid))
break;
}
}
if(machine.size()==((sz*mid)))
{
s=mid;
for(auto&i:cur)
rem.erase(i);
}
else{
e=mid;
rem.clear();
for(auto&i:cur)
{
rem.insert(i);
machine.erase(i);
move_outside(i);
}
}
}
return s;
}
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... |