#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 lin1, int lin2); int main() { f(0, 0, 199, 199); return 0; } void f(int x1, int y1, int x2, int y2) { int col = (y1 + y2) / 2; if(x1 > x2 || y1 > y2) { return ; } int pos = bin_search(col, x1, x2); if(gasit) { return ; } f(x1, col + 1, pos, y2); if(!gasit) { f(pos + 1, y1, x2, col - 1); } } int bin_search(int nr, int lin1, int lin2) { int put = 1; while(put <= lin2 - lin1 + 1) { put <<= 1; } put >>= 1; int pos = lin1 - 1; for(;put;put >>= 1) { int aux = pos + put; if(aux <= lin2) { int x = Get(aux, nr); if(x == 0) { gasit = 1; return -2; } if(x < 0) { pos = aux; } } } return pos; }