- 最初三分探索してた。二分探索で良いのにね。
- 最初にxを探して、見つかったらマンハッタン距離の残りの差分がyまでの距離だから、yは探索しなくて済むね。
#include<bits/stdc++.h>
using namespace std;
inline int check(int minx,int maxx){
cout<<minx<<" "<<0<<"\n";
int d1;cin>>d1;
if(d1==0)return -1;
cout<<maxx<<" "<<0<<"\n";
int d2;cin>>d2;
if(d2==0)return -1;
if(d1==d2)return 0;
else if(d1>d2)return 2;
else return 1;
}
int main(){
int minx=0,maxx=100000;
int resx=0;
bool flag=0;
while(maxx-minx>1){
int temp=check(minx,maxx);
if(temp==-1)return 0;
else if(temp==0){
resx=(minx+maxx)/2;
flag=1;
break;
}else if(temp==1){
maxx=(minx+maxx)/2;
}else{
minx=(minx+maxx)/2;
}
}
if(!flag){
int temp=check(minx,maxx);
if(temp==1)resx=minx;
else resx=maxx;
}
cout<<resx<<" "<<0<<endl;
int dd;cin>>dd;
cout<<resx<<" "<<dd<<endl;
return 0;
}