CF1599H.Hidden Fortress

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

This is an interactive problem!

As part of your contribution in the Great Bubble War, you have been tasked with finding the newly built enemy fortress. The world you live in is a giant 109×10910^9 \times 10^9 grid, with squares having both coordinates between 11 and 10910^9 .

You know that the enemy base has the shape of a rectangle, with the sides parallel to the sides of the grid. The people of your world are extremely scared of being at the edge of the world, so you know that the base doesn't contain any of the squares on the edges of the grid (the xx or yy coordinate being 11 or 10910^9 ).

To help you locate the base, you have been given a device that you can place in any square of the grid, and it will tell you the manhattan distance to the closest square of the base. The manhattan distance from square (a,b)(a, b) to square (p,q)(p, q) is calculated as ap+bq|a−p|+|b−q| . If you try to place the device inside the enemy base, you will be captured by the enemy. Because of this, you need to make sure to never place the device inside the enemy base.

Unfortunately, the device is powered by a battery and you can't recharge it. This means that you can use the device at most 4040 times.

输入格式

The input contains the answers to your queries.

输出格式

Your code is allowed to place the device on any square in the grid by writing "? ii jj " (1i,j109)(1 \leq i,j \leq 10^9) . In return, it will recieve the manhattan distance to the closest square of the enemy base from square (i,j)(i,j) or 1-1 if the square you placed the device on is inside the enemy base or outside the grid.

If you recieve 1-1 instead of a positive number, exit immidiately and you will see the wrong answer verdict. Otherwise, you can get an arbitrary verdict because your solution will continue to read from a closed stream.

Your solution should use no more than 4040 queries.

Once you are sure where the enemy base is located, you should print "! xx yy pp qq " (1xp109,1yq109)(1 \leq x \leq p\leq 10^9, 1 \leq y \leq q\leq 10^9) , where (x,y)(x, y) is the square inside the enemy base with the smallest xx and yy coordinates, and (p,q)(p, q) is the square inside the enemy base with the largest xx and yy coordinates. Note that answering doesn't count as one of the 40 queries.

After printing a query or printing the answer, do not forget to output end of line and flush the output. Otherwise, you will get idleness limit exceeded. To do this, use:

  • fflush(stdout) or cout.flush() in C++;
  • System.out.flush() in Java;
  • flush(output) in Pascal;
  • stdout.flush() in Python;
  • See the documentation for other languages.

输入输出样例

  • 输入#1

    1
    1
    2
    1

    输出#1

    ? 2 2
    ? 5 5
    ? 4 7
    ? 1 5
    ! 2 3 4 5
首页