Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long double ld;
- typedef int64_t ll;
- int ask (ll x, ll y) {
- cout << x << ' ' << y << endl;
- int res;
- cin >> res;
- return res;
- }
- int main () {
- ll n;
- cin >> n;
- ll x0 = 1, x1 = n + 1, x2 = n + 1;
- ll y0 = 1, y1 = n + 1, y2 = n + 1;
- while (1) {
- ld s00 = ld(x1 - x0) * ld(y1 - y0);
- ld s10 = ld(x2 - x1) * ld(y1 - y0);
- ld s01 = ld(x1 - x0) * ld(y2 - y1);
- ll x = (x0 + x1) / 2;
- ll y = (y0 + y1) / 2;
- if (s10 > s00 + s01) {
- x = x1;
- }
- if (s01 > s00 + s10) {
- y = y1;
- }
- int res = ask(x, y);
- if (res == 1) {
- x0 = x + 1;
- } else if (res == 2) {
- y0 = y + 1;
- } else if (res == 3) {
- x1 = x;
- y1 = y;
- } else {
- break;
- }
- if (x1 <= x0) {
- x1 = x2;
- y2 = y1;
- }
- if (y1 <= y0) {
- y1 = y2;
- x2 = x1;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement