이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
while(!pos.empty()){
move_outside(*pos.begin());
pos.erase(pos.begin());
}
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... |