# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
798936 | LIF | Rarest Insects (IOI22_insects) | C++17 | 250 ms | 344 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 <vector>
using namespace std;
bool vis[300005];
bool can[300005];
int cnt = 0;
int k = 0;
bool check(int now,int N)
{
//if(now == 1)return true;
for(int i=0;i<=N-1;i++)
{
can[i] = true;
vis[i] = false;
}
vector<int> vv;
for(int i=0;i<=N-1;i++)
{
move_inside(i);
if(press_button() > now)
{
move_outside(i);
vv.push_back(i);
vis[i] = true;
}
}
for(int i=0;i<=N-1;i++)if(vis[i] == false)move_outside(i);
for(int i=0;i<vv.size();i++)
{
move_inside(vv[i]);
if(press_button() >= 2)move_outside(vv[i]);
}
for(int i=0;i<=N-1;i++)
{
if(vis[i] == true)continue;
move_inside(i);
if(press_button() >= 2)can[i] = false;
move_outside(i); // we must move_outside all of things, otherwise it will impact other checks.
}
for(int i=0;i<=N-1;i++)
{
if(can[i] == true && vis[i] == false)return true;
}
return false;
}
int min_cardinality(int N) {
int l = 1;
vector<int> cnt;
for(int i=0;i<=N-1;i++)
{
move_inside(i);
if(press_button() >= 2)move_outside(i);
else cnt.push_back(i);
}
for(int i=0;i<=N-1;i++)move_outside(i);
k = cnt.size();
int r = N/k;
int ans = N;
while(l <= r)
{
int mid = (l+r)>>1;
if(check(mid,N) == true)
{
r = mid-1;
ans = mid;
}
else l = mid+1;
}
return ans;
}
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... |