#include #include #include using namespace std; int main(int argc, const char* argv[]) { int lowX = 0; // int lowY = 0; int highX = 100000; // int highY = 100000; int x = 0; int y = 0; map m; auto fxy = [&](int x, int y) { uint64_t key = 100001 * (y + 1) + x; if (m[key]) return m[key]; cout << x << " " << y << endl; int d; cin >> d; return d; }; auto fyx = [&](int x, int y) { uint64_t key = 100001 * (x + 1) + y; if (m[key]) return m[key]; cout << y << " " << x << endl; int d; cin >> d; return d; }; // auto f = fxy; function f = fxy; int i = 0; for (int k = 0; k < 2; k++) { for (; i < 100; i++) { int ld = f(lowX, y); if (ld == 0) return 0; int hd = f(highX, y); if (hd == 0) return 0; int gap = highX - lowX; if (ld < hd) { x = lowX; highX -= gap / 2; } if (ld > hd) { x = highX; lowX += gap / 2; } if (ld == hd) { x = (ld + hd) / 2; break; } if (gap <= 1) break; } if (i == 100) break; y = x; x = 0; lowX = 0; highX = 100000; f = fyx; i++; } return 0; }