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>
using namespace std;
const int maxn=2010;
int n;
int tren[maxn];
int perm[maxn];
int unutra=0;
int korak=1;
int raz;
void ubaci(int i){
if(tren[i]!=0) return;
tren[i]=korak;
move_inside(perm[i]);
unutra++;
}
void izbaci(int i){
if(tren[i]==0) return;
tren[i]=0;
move_outside(perm[i]);
unutra--;
}
int pitaj(){
return press_button();
}
int nadji(){
for(int i=0;i<n;i++){
ubaci(i);
if(pitaj()>1){
izbaci(i);
}
}
return unutra;
}
mt19937 rng(23479);
bool probaj(int gran){ // da li je >=
for(int i=0;i<n;i++){
ubaci(i);
if(pitaj()>gran){
izbaci(i);
}
}
int kurac=unutra;
for(int i=0;i<n;i++) izbaci(i);
if(kurac==raz*gran) return true;
return false;
}
int min_cardinality(int _n){
n=_n;
for(int i=0;i<n;i++) perm[i]=i;
shuffle(perm,perm+n,rng);
raz=nadji();
int l=1,r=n/raz;
int res=-1;
while(l<=r){
int mid=l+(r-l)/2;
if(probaj(mid)){
res=mid;
l=mid+1;
}else r=mid-1;
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |