이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "insects.h"
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define pii pair<int, int>
#define piii pair<pii, int>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define f first
#define s second
#define oo 1000000001
#define eb emplace_back
#define pb push_back
#define mpr make_pair
#define size(v) (int)v.size()
#define ln '\n'
#define ull unsigned long long
#define ll long long
#define all(v) v.begin(), v.end()
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int min_cardinality(int N) {
vector<bool>inside(N, false);
vector<bool>fixed(N, false);
vi machine;
for (int i = 0; i < N; ++i) {
move_inside(i);
if (press_button() == 2) {
move_outside(i);
} else {
inside[i] = fixed[i] = true;
machine.eb(i);
}
}
int uni = size(machine);
int l = 1, r = N / uni;
while (l < r) {
int mid = (l + r + 1) >> 1;
for (int i = 0; i < N; ++i) {
if (uni * mid == size(machine)) break;
if (!fixed[i]) {
move_inside(i);
if (press_button() > mid) {
move_outside(i);
} else {
inside[i] = true;
machine.eb(i);
}
}
}
if (uni * mid == size(machine)) {
l = mid;
for (int i = 0; i < N; ++i) {
if (inside[i]) fixed[i] = true;
}
} else {
r = mid - 1;
for (int i = 0; i < N; ++i) {
if (!inside[i]) {
fixed[i] = true;
} else if (!fixed[i]) {
move_outside(i);
inside[i] = false;
machine.pop_back();
}
}
}
}
return l;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |