#include #include #include #include #include #include #include #include #include #include #include using namespace std; int N, M, ap[209][209], ap2[209][209], val[209][209], s[209][209]; int Ask (int i, int j) { if (ap2[i][j]) return val[i][j]; ap2[i][j] = 1; int ans; printf ("%d %d\n", i - 1, j - 1); fflush (stdout); scanf ("%d", &ans); val[i][j] = ans; fflush (stdout); if (ans == 0) exit (0); return ans; } int sum (int a1, int b1, int a2, int b2) { return s[a2][b2] - s[a1 - 1][b2] - s[a2][b1 - 1] + s[a1 - 1][b1 - 1]; } int main() { //freopen ("input", "r", stdin); //freopen ("output", "w", stdout); ///scanf ("%d %d", &N, &M);fflush (stdout); N = M = 200; while (1) { for (int i=1; i<=N; i++) for (int j=1; j<=M; j++) s[i][j] = s[i-1][j]+s[i][j-1]-s[i-1][j-1]+(1-ap[i][j]); int bst = 0, x, y; for (int i=1; i<=N; i++) for (int j=1; j<=M; j++) { int curr = min (s[i][j], sum (i, j, N, M)); if (curr > bst) bst = curr, x = i, y = j; } int val = Ask (x, y); if (val == 0) return 0; if (val > 0) { for (int i=x; i<=N; i++) for (int j=y; j<=M; j++) ap[i][j] = 1; } else { for (int i=1; i<=x; i++) for (int j=1; j<=y; j++) ap[i][j] = 1; } } return 0; }