# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
652934 | grt | Rarest Insects (IOI22_insects) | C++17 | 0 ms | 0 KiB |
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"
//GRT_2018
#include <bits/stdc++.h>
#define PB push_back
#define ST first
#define ND second
//mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
using namespace std;
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
const int nax = 2010;
bool discarded[nax];
int baseLength(vi &v) {
vi taken = {};
for(int x : v) {
move_inside(x);
taken.PB(x);
int w = press_button();
if(w >= 2) {
move_outside(x);
taken.pop_back();
}
}
for(int x : taken) {
move_outside(x);
discarded[x] = true;
}
return (int)taken.size();
}
int min_cardinality(int n) {
vi allowed = {};
for(int i = 0; i < n; ++i) {
allowed.PB(i);
}
int k = baseLength(allowed);
for(int i = 2; i <= n; ++i) {
allowed.clear();
for(int j = 0; j < n; ++j) {
if(!dicarded[j]) {
allowed.PB(j);
}
}
int k2 = baseLength(allowed);
if(k2 < k) {
return i - 1;
}
}
return n;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
}