This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define ONLINE_JUDGE
#include <bits/stdc++.h>
#include "insects.h"
using namespace std;
#define MASK(x) (1LL << (x))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (int i = 0, _n = n; i < _n; ++i)
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define FORE(it, s) for (__typeof(s.begin()) it = (s).begin(); it != (s).end(); ++it)
template <class U, class V> bool maximize(U &A, const V &B) { return (A < B) ? (A = B, true) : false; }
template <class U, class V> bool minimize(U &A, const V &B) { return (A > B) ? (A = B, true) : false; }
set <int> inside;
vector <int> insect;
/*
void add(int i) {
inside.insert(i);
move_inside(i);
}
void del(int i) {
inside.erase(inside.find(i));
move_outside(i);
}
*/
void print_vector(vector <int> v) {
for (auto x : v) cout << x << " ";
cout << '\n';
}
int min_cardinality(int n) {
insect.assign(n, 0);
iota(ALL(insect), 0);
set <int> s;
int ans = 0;
int D = 0;
vector <int> List, Del;
REP(i, n) {
move_inside(i); D++;
if(press_button() > 1) move_outside(i), --D, List.push_back(i);
else Del.push_back(i);
}
for (auto x : Del) move_outside(x);
if(2 * D > n) return 1;
while((int) List.size()) {
ans++;
vector <int> newList;
Del.clear();
int val = 0;
REP(i, (int) List.size()) {
int x = List[i];
move_inside(x);
val++;
if(press_button() > 1) {
move_outside(x);
newList.push_back(x);
val--;
} else Del.push_back(x);
}
for (auto x : Del) move_outside(x);
List = newList;
if(val != D) return ans;
}
return ans + 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |