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>
#define ll long long
#define ull unsigned ll
#define pii pair<int, int>
#define piii pair<int, pii>
#define pb push_back
#define all(v) v.begin(), v.end()
#define size(v) v.size()
#define f first
#define s second
#define INF 1e9
using namespace std;
bool check(int x, int Types, int N, set<int>&pos){
for(int i = 0; i < N; ++i){
move_inside(i);
if(press_button() > x){
move_outside(i);
}else{
pos.insert(i);
}
}
int Size = size(pos);
if(Size == x * Types){
return true;
}
return false;
}
int min_cardinality(int N) {
set<int>pos;
for(int i = 0; i < N; ++i){
move_inside(i);
if(press_button() > 1){
move_outside(i);
}else{
pos.insert(i);
}
}
int Types = size(pos);
int low = 2, high = N / Types, best = 1;
while(low <= high){ // is it possible to encounter at least mid element for every type?
int mid = (low + high) >> 1;
if(check(mid, Types, N, pos)){
low = mid + 1;
best = mid;
}else{
high = mid - 1;
}
}
return best;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |