# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1060724 | AdamGS | Rarest Insects (IOI22_insects) | C++17 | 51 ms | 1220 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"
#include<bits/stdc++.h>
using namespace std;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
vector<int>V, usun;
int n;
int solve(int l, int r, vector<int>czy) {
if(l==r) return l;
int mid=(l+r+1)/2;
vector<int>P;
rep(i, n) if(czy[i]) {
move_inside(i);
if(press_button()==mid+1) move_outside(i);
else P.pb(i);
}
bool ok=true;
vector<int>A, B;
rep(j, V.size()) if(!usun[j]) {
int i=V[j];
move_inside(i);
if(press_button()<=mid) {
ok=false;
A.pb(j);
} else B.pb(j);
move_outside(i);
}
if(ok) {
for(auto i : P) czy[i]=0;
return solve(mid, r, czy);
}
for(auto i : B) usun[i]=1;
rep(i, n) czy[i]=0;
for(auto i : P) czy[i]=1;
for(auto i : P) move_outside(i);
return solve(l, mid-1, czy);
}
int min_cardinality(int _n) {
n=_n;
rep(i, n) {
move_inside(i);
if(press_button()==1) V.pb(i);
else move_outside(i);
}
for(auto i : V) move_outside(i);
vector<int>czy(n, 1);
for(auto i : V) czy[i]=0;
rep(i, V.size()) usun.pb(0);
return solve(0, (n-V.size())/V.size(), czy)+1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |