/* -*- coding: utf-8 -*- * * 3161.cc: No.3161 Find Presents - yukicoder */ #include #include #include #include using namespace std; /* constant */ const int MAX_N = 100; const int MAX_X = 1000000; const int MAX_Y = 1000000; /* typedef */ using tp4 = tuple; using qtp4 = queue; /* global variables */ int xs[MAX_N], ys[MAX_N]; /* subroutines */ int query(int x0, int x1, int y0, int y1) { // [x0,x1), [y0, y1) if (x0 < x1 && y0 < y1) { printf("? %d %d %d %d\n", x0, x1 - 1, y0, y1 - 1); fflush(stdout); int r; scanf("%d", &r); if (r < 0) exit(0); return r; } return 0; } /* main */ int main() { int n = 0; qtp4 q; q.push({0, MAX_X + 1, 0, MAX_Y + 1}); while (! q.empty()) { auto [x0, x1, y0, y1] = q.front(); q.pop(); if (x0 + 1 < x1 || y0 + 1 < y1) { int x2 = (x0 + x1) / 2, y2 = (y0 + y1) / 2; if (query(x0, x2, y0, y2)) q.push({x0, x2, y0, y2}); if (query(x2, x1, y0, y2)) q.push({x2, x1, y0, y2}); if (query(x0, x2, y2, y1)) q.push({x0, x2, y2, y1}); if (query(x2, x1, y2, y1)) q.push({x2, x1, y2, y1}); } else xs[n] = x0, ys[n] = y0, n++; } printf("! %d\n", n); for (int i = 0; i < n; i++) printf("%d %d\n", xs[i], ys[i]); fflush(stdout); //for (int i = 0; i < 1e9; i++); return 0; }