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<bits/stdc++.h>
#include "insects.h"
using namespace std;
int BO[2009];
deque <int> de;
int a,b,c,d,e,i,j,ii,jj,zx,xc,f[2009],fx[2009],p[2009],pi,lef,rig,mid;
void ins(int q){
if(BO[q]==1) return;
de.push_back(q);
BO[q]=1;
move_inside(q-1);
}
void outs(int q){
if(BO[q]==0) return;
de.pop_back();
BO[q]=0;
move_outside(q-1);
}
int ask(){
return press_button();
}
void clea(){
for(int h=1; h<=a; h++){
if(BO[h]==1){
outs(h);
BO[h]=0;
}
}
}
int min_cardinality(int N) {
a=N;
for(i=1; i<=a; i++){
ins(i);
if(ask()==2){
outs(i);
continue;
}
pi++;p[pi]=i;
}
clea();
lef=0;rig=a/pi+1;
while(1){
if(lef+1>=rig) break;
mid=(lef+rig)/2;zx=0;
while(de.size()) de.pop_front();
for(i=1; i<=a; i++){
ins(i);zx++;
if(ask()==mid+1){
outs(i);zx--;
}
}
//clea();
if(zx==mid*pi){
lef=mid;
}else{
rig=mid;
while(de.size()){
outs(de.back());
de.pop_back();
}
}
}
return lef;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |