https://codeforces.com/contest/788/problem/D
坐标系上的交互有一种常见套路,就是抓住一些关键的线
- x轴y轴
- y=x(就是此题)
然后考虑接下来怎么做。
交互题常见有二分的套路,此题我们可以考虑推广到分治。
不断判断mid,然后就可以求出最近的范围,并递归下去即可
#include<bits/stdc++.h>
using namespace std;
//#define int long long
inline int read(){int x=0,f=1;char ch=getchar(); while(ch<'0'||
ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){
x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
#define Z(x) (x)*(x)
#define pb push_back
//mt19937 rand(time(0));
//mt19937_64 rand(time(0));
//srand(time(0));
//#define N
//#define M
//#define mo
int n, m, i, j, k, T;
int l, r;
vector<int>v1, v2, G;
int R() { // int 范围内随机数
return rand()|(rand()<<15);
}
//void check(int x) {
// int a=R()%(int)(2e8)-1e8, b=R()%(int)(2e8)-1e8;
// printf("0 %d %d", x, a); cout<<endl; cin>>a;
// printf("0 %d %d", x, b); cout<<endl; cin>>b;
// if(a==0 && b==0) return v1.pb(x), void();
// else return v2.pb(x), void();
//}
int wen(int x, int y) {
printf("0 %d %d\n", x, y); cout<<endl;
int a; cin>>a;
return a;
}
void solve(int l, int r) {
if(l>r) return ;
int mid=(l+r)>>1, x;
printf("0 %d %d", mid, mid); cout<<endl;
cin>>x;
if(x==0) {
G.pb(mid);
solve(l, mid-1); solve(mid+1, r);
return ;
}
solve(l, mid-x); solve(mid+x, r);
}
signed main()
{
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
// T=read();
// while(T--) {
//
// }
srand(time(0));
l=-1e8; r=1e8;
solve(l, r);
for(auto i : G) {
int a=R()%(int)2e8-1e8, b=R()%(int)2e8-1e8;
if(wen(i, a)==0 && wen(i, b)==0) v1.pb(i);
if(wen(a, i)==0 && wen(b, i)==0) v2.pb(i);
}
printf("1 %d %d\n", v1.size(), v2.size());
for(auto i : v1) printf("%d ", i); printf("\n");
for(auto i : v2) printf("%d ", i); printf("\n");
cout<<endl;
return 0;
}