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>
#define ll long long
using namespace std;
const double r = 0.45;
int min_cardinality(int N)
{
vector<int> remain;
int g = 0;
{
vector<int> single;
for (int i = 0; i < N; i++)
{
move_inside(i);
if (press_button() == 2)
move_outside(i);
else
single.emplace_back(i), g++;
}
for (int i : single)
move_outside(i);
}
int L = 1, R = N / g;
for (int i = 0; i < N; i++)
remain.emplace_back(i);
int lazy = 0;
while (L < R)
{
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
shuffle(remain.begin(), remain.end(), rd);
int k = L * (1.0 - r) + R * r;
vector<int> small, large;
for (int i : remain)
{
if (small.size() + lazy == g * (k + 1))
{
large.emplace_back(i);
continue;
}
move_inside(i);
if (press_button() > k + 1)
{
move_outside(i);
large.emplace_back(i);
}
else
small.emplace_back(i);
}
if (small.size() + lazy == g * (k + 1))
L = k + 1, remain = large, lazy = g * (k + 1);
else
{
for (int i : small)
move_outside(i);
R = k, remain = small;
}
}
return L;
}
Compilation message (stderr)
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:38:37: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
38 | if (small.size() + lazy == g * (k + 1))
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
insects.cpp:52:33: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
52 | if (small.size() + lazy == g * (k + 1))
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |