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 <iostream>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
const int mx = 2'000;
vi ins(mx, 0);
int ct = 0;
void move_in(int i)
{
if(ins[i])
return;
ins[i] = 1;
move_inside(i);
ct++;
}
void move_out(int i)
{
if(!ins[i])
return;
ins[i] = 0;
move_outside(i);
ct--;
}
int min_cardinality(int N)
{
int tot = 0;
vi is_basic(N, 0);
for(int i = 0; i < N; i++)
{
move_in(i);
if(press_button() >= 2)
move_out(i);
else
{
is_basic[i] = 1;
tot++;
}
}
for(int i = 0; i < N; i++)
move_out(i);
// cerr << "tot = " << tot << '\n';
vi currlist;
for(int i = 0; i < N; i++)
currlist.push_back(i);
int uplim = 0;
for(int e = 10; e >= 0; e--)
{
int newlim = uplim + (1<<e);
vi inlist, outlist;
for(int i : currlist)
{
if(ct > newlim * tot)
{
outlist.push_back(i);
}
move_in(i);
if(press_button() <= newlim)
inlist.push_back(i);
if(press_button() > newlim)
{
move_out(i);
outlist.push_back(i);
}
else
inlist.push_back(i);
}
if(ct == newlim * tot)
{
currlist = outlist;
uplim = newlim;
}
else
{
for(int i : inlist)
move_out(i);
currlist = inlist;
}
}
return uplim;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |