#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;
vi inside(LIM,0);
void add(int p) {
if (inside[p]) return;
inside[p] = 1;
move_inside(p);
}
void remove(int p) {
if (!inside[p]) return;
inside[p] = 0;
move_outside(p);
}
int min_cardinality(int N) {
vi machine;
vi cand;
for (int i = 0;i<N;i++) cand.push_back(i);
while (1) {
int bocuk = 0;
for (auto it : cand) {
add(it);
int y = press_button();
if (y == 1) bocuk++;
else remove(it);
}
if (bocuk == 1) return cand.size();
int t = big(cand)/bocuk;
for (auto it : cand) remove(it);
vi dumb;
for (auto it : cand) {
add(it);
int y = press_button();
if (y > t) {
dumb.push_back(it);
remove(it);
}
}
for (auto it : cand) remove(it);
for (auto it : dumb) add(it);
vi nxt;
for (auto it : cand) {
add(it);
int y = press_button();
if (y == 1) nxt.push_back(it);
remove(it);
}
if ( big(nxt) == big(cand)) return t;
cand = nxt;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |