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>
#ifndef EVAL
#include "stub.cpp"
#endif
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define long unsigned long
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define lb lower_bound
#define ub upper_bound
#define sz(v) int((v).size())
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define PI 2*acos(0.0)
int min_cardinality(int n) {
int different = 1;
vector <int> inside;
move_inside(0);
inside.pb(0);
for (int i = 1; i < n; i++) {
move_inside(i);
if (press_button() > 1) {
move_outside(i);
}
else {
different++;
inside.pb(i);
}
}
for (auto x : inside) {
move_outside(x);
}
int l = 2, r = n + 1;
vector <int> used(n);
while (l < r) {
int mid = (l + r) >> 1;
inside.clear();
for (int i = 0; i < n; i++) {
if (used[i] == 1) continue;
move_inside(i);
if (press_button() > mid) {
move_outside(i);
}
else {
used[i] = 1;
inside.pb(i);
}
}
if (sz(inside) == different * mid) {
l = mid + 1;
}
else if (sz(inside) < different * mid) {
r = mid;
for (auto x : inside) {
move_outside(x);
used[x] = 0;
}
}
else {
r = mid;
}
}
return l - 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... |