#include "insects.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
//#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define ff first
#define ss second
#define sp << " " <<
#define all(x) x.begin(),x.end()
#define big(x) ((int)(x.size()))
using namespace std;
const int MOD = 1e9+7, LIM = 1e6+1, inf = 2e9;
int min_cardinality(int N) {
vi machine;
vi cand,cand2;
for (int i = 0;i<N;i++) cand.push_back(i);
vi inside(N,0);
while (1) {
for (auto it : cand) if (!inside[it]) move_inside(it),inside[it] = 1;
int x = press_button();
vi rem;
for (auto it : cand) {
move_outside(it);
inside[it] = 0;
int y = press_button();
if (y<x) {
move_inside(it);
inside[it] = 1;
break;
}
}
for (auto it : cand) {
if (inside[it]) move_outside(it);
inside[it] = 0;
int y = press_button();
if (y<x) rem.push_back(it);
else continue;
if (!inside[it]) move_inside(it);
inside[it] = 1;
}
if (rem.size() == cand.size()) return x;
if (rem.empty()) return x;
for (auto it : cand) {
if (!count(all(rem),it)) {
cand2.push_back(it);
}
else {
move_outside(it);
}
}
cand.swap(cand2);
cand2.clear();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |