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>
using namespace std;
const int N = 2e3 + 10;
bool inside[N];
set<int> items;
int n;
int min_cardinality(int _n) {
n = _n;
for (int i = 0; i < n; ++i) items.insert(i);
int types = 0;
for (int i = 0; i < n; ++i) {
inside[i] = 1;
move_inside(i);
++types;
if (press_button() == 2) {
inside[i] = 0;
move_outside(i);
--types;
}
}
for (int i = 0; i < n; ++i) if (inside[i]) {
inside[i] = 0;
move_outside(i);
}
int res = -1;
while (!~res) {
int mid = items.size() / types;
set<int> turn;
int cnt = 0;
for (int i : items) {
if (!inside[i]) {
inside[i] = 1;
move_inside(i);
turn.insert(i);
if (press_button() > mid) {
inside[i] = 0;
move_outside(i);
turn.erase(i);
}
}
cnt += inside[i];
}
if (cnt == types * mid) {
res = mid;
break;
}
else {
set<int> nxt;
for (int i : items) if (inside[i]) nxt.insert(i);
for (int i : turn) {
inside[i] = 0;
move_outside(i);
}
items = nxt;
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |