#include "prize.h"
#include <bits\stdc++.h>
using namespace std;
const int maxn = 200005;
bool vis[maxn];
int lp;
//rx right of r
int find(int l,int r,int lx,int rx) //lx left of l
{
int mid,tmp,nm;
mid=(l+r)/2-1;
while(vis[mid] && mid<=r)mid++;
if(mid>r)
{
while(vis[mid] && mid>=l)mid--;
if(mid<l)return 0; // 0 not find any thing
}
vector<int> res = ask(mid);
vis[mid]=true;
if(res[0]+res[1]==0)return mid;
if(res[0]+res[1]==lp)
{
if(res[0]-lx>0) // left not empty
{
tmp=find(l,mid-1,lx,res[1]);
if(tmp)return tmp;
}
if(res[1]-rx>0) // right not empty
{
tmp=find(mid+1,r,res[0],rx);
if(tmp)return tmp;
}
}
else if(tmp=find(l,r,lx,rx))return tmp;
return 0;
}
int find_best(int n) {
int mx=-1,nm,id;
//vector<int> res = ask(i);
for(int i=0;i<476;i++)
{
vector<int> res = ask(i);
int tmp = res[0] + res[1];
if(tmp==0)
{
//cout<<i;
return i;
}
if(tmp>mx)
{
mx=tmp;
id=i;
nm=1;
}
if(tmp==mx)nm++;
}
lp=mx; //lp refers to lollipop
memset(vis,false,sizeof(vis));
int tp=find(476,n,476-nm,0);
//cout<<tp;
return tp;
return 0;
}
Compilation message
prize.cpp:2:10: fatal error: bits\stdc++.h: No such file or directory
#include <bits\stdc++.h>
^~~~~~~~~~~~~~~
compilation terminated.