#include #include using namespace std; int gasit; int Get(int line, int col) { cout << line << ' ' << col << '\n'; int val; cout.flush(); cin >> val; return val; } void f(int x1, int y1, int x2, int y2); int bin_search(int nr, int col1, int col2); int main() { f(0, 0, 199, 199); return 0; } void f(int x1, int y1, int x2, int y2) { int lin = (x1 + x2) / 2; if(x1 > x2 || y1 > y2) { return ; } int pos = bin_search(lin, y1, y2); if(gasit) { return ; } f(x1, pos + 1, lin - 1, y2); if(!gasit) { f(lin + 1, y1, x2, pos); } } int bin_search(int nr, int col1, int col2) { int put = 1; while(put <= col2 - col1 + 1) { put <<= 1; } put >>= 1; int pos = col1 - 1; for(;put;put >>= 1) { int aux = pos + put; if(aux <= col2) { int x = Get(aux, nr); if(x == 0) { gasit = 1; return -2; } if(x < 0) { pos = aux; } } } return pos; }