# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
799773 | LIF | Rarest Insects (IOI22_insects) | C++17 | 64 ms | 428 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>
#include<bits/stdc++.h>
using namespace std;
bool vis[300005];
bool can[300005];
int k = 0;
vector<int> vv2;
bool rub[300005];
vector<int> vv1;
int nown;
bool ys[300005];
int cc[300005];
bool check(int now,int N,int minn)
{
//if(now == 1)return true;
vector<int> vv;
for(int i=0;i<=N-1;i++)vis[i] = false;
for(int i=0;i<=N-1;i++)
{
if(rub[i] == false && ys[i] == false)
{
move_inside(i);
ys[i] = true;
if(press_button() > now+1)
{
move_outside(i);
vv.push_back(i);
vis[i] = true;
ys[i] = false;
}
else vv2.push_back(i);
}
}
/* cout<<"now: "<<now<<endl;
cout<<"nown: "<<nown<<endl;
cout<<"nown-vv.size(): "<<N-vv.size()<<" "<<(now+1) * k<<endl;
cout<<"vv[i] ";
for(int i=0;i<vv.size();i++)cout<<vv[i]<<" ";
cout<<endl;*/
if(nown-vv.size() < (now+1) * k)
{
for(int i=0;i<vv.size();i++)rub[vv[i]] = true;
for(int i=0;i<=N-1;i++)
{
if(vis[i] == false && rub[i] == false && ys[i] == true)
{
move_outside(i);
ys[i] = false;
if(press_button() <= minn)break;
}
}
nown -= vv.size();
return true;
}
else
{
return false;
}
}
bool first[40005];
int min_cardinality(int N) {
nown = 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);
first[i] = true;
}
else cnt.push_back(i);
}
for(int i=0;i<=N-1;i++)
{
if(first[i] == false)move_outside(i);
}
k = cnt.size();
//if(k == 1)return N;
int r = (N)/k;
int ans = (N)/k;
while(l <= r)
{
int mid = (l+r)>>1;
if(check(mid,N,l) == 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... |