#include #include using namespace std; int rez1 = 1, rez2 = 1; int mat[200][200]; void divide(int x, int y, int x1, int y1){ if (rez1 == 0 or rez2 == 0) return; if (x >= x1 or y >= y1) return; if (mat[x][y] != 0 and mat[x1][y1] != 0) return; if (mat[x][y] != 0) rez1 = mat[x][y]; else { cout << x << " " << y << '\n'; cout.flush(); cin >> rez1; } if (rez1 == 0) return; if (mat[x1][y1] != 0) rez2 = mat[x1][y1]; else { cout << x1 << " " << y1 << '\n'; cout.flush(); cin >> rez2; } if (rez2 == 0) return; mat[x][y] = rez1; mat[x1][y1] = rez2; if (rez1 < 0 and rez2 > 0){ divide(x, y, x + (x1 - x) / 2, y + (y1 - y) / 2); divide(x, y + (y1 - y) / 2 + 1, x + (x1 - x) / 2, y1); divide(x + (x1 - x) / 2 + 1, y, x1, y + (y1 - y) / 2); divide(x + (x1 - x) / 2 + 1, y + (y1 - y) / 2 + 1, x1, y1); } } int main(){ divide(0, 0, 199, 199); }