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;
int cnt,ch[2050],mi=2050;
int min_cardinality(int N) {
int i,j,now,s=-1,ans=1;
for(i=0;i<N;i++){
move_inside(i);
if(press_button()==1) cnt++;
else{
move_outside(i);
}
}
if(cnt*cnt>=N){
while(1){
now=0;
for(i=0;i<N;i++){
if(ch[i]==1) continue;
move_inside(i);
ch[i]=1;
if(press_button()==ans) {
now++;
continue;
}
move_outside(i);
ch[i]=0;
}
if(s==-1){
s=now;
ans++;
}else{
if(s==now) ans++,s=now;
else return ans-1;
}
}
}else{
for(i=0;i<N;i++){
now=0;
if(ch[i]!=0) continue;
move_inside(i);
ch[i]=i+N;
now++;
for(j=0;j<N;j++){
if(j==i||ch[j]!=0) continue;
move_inside(j);
if(press_button()==now+1){
ch[j]=i+N;
now++;
}else{
move_outside(j);
}
}
for(j=0;j<N;j++){
if(ch[j]==i+N) move_outside(j);
}
mi=min(mi,now);
}
return mi;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |