题库练习 Guess the Perimeter
← 上一题 下一题 →

A14407 | Guess the Perimeter

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Let us call a point of the plane admissible if its coordinates are positive integers less than or equal to $200$ .

There is an invisible rectangle such that:

- its vertices are all admissible;
- its sides are parallel to the coordinate axes;
- its area is strictly positive.

Your task is to guess the perimeter of this rectangle.In order to guess it, you may ask at most $4$ queries.

In each query, you choose a nonempty subset of the admissible points and you are told how many of the chosen points are inside or on the boundary of the invisible rectangle.

输入格式

无

输出格式

To ask a query (of the kind described in the statement), you shall print two lines:

- In the first line print "? $k$ " (without the quotes) where $k$ ( $k\ge 1$ ) is the number of chosen points.
- In the second line print $2k$ integers $x_1,\, y_1,\, x_2,\, y_2,\, \dots,\, x_k,\, y_k$ ( $1\le x_i,y_i\le 200$ for $i=1,2,\dots,k$ ) where $(x_1, y_1),\,(x_2, y_2),\,(x_3, y_3),\, \dots,\,(x_k, y_k)$ are the $k$ distinct admissible chosen points (the order of the points is not important).

After this, you should read an integer — the number of chosen points that are inside or on the boundary of the invisible rectangle.When you have identified the perimeter $p$ of the invisible rectangle, you must print "! $p$ " (without quotes) and terminate your program.

If you ask more than $4$ queries or if one of the queries is malformed, the interactor terminates immediately and your program receives verdict Wrong Answer.

The interactor may be adaptive (i.e., the hidden rectangle may not be chosen before the beginning of the interaction).

After printing a query 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 documentation for other languages.

Hacks

To hack a solution, use the following format.

The input has only one line, containing the $4$ integers $x_0$ , $y_0$ , $x_1$ , $y_1$ ( $1\le x_0<x_1\le 200$ , $1\le y_0 < y_1 \le 200$ ) — $(x_0,y_0)$ is the bottom-left vertex of the hidden rectangle and $(x_1, y_1)$ is the top-right vertex of the hidden rectangle.

Note that for hacks the interaction won't be adaptive.

输入输出样例

输入 #1
13 5 123 80
输出 #1

                            
输入 #2
2 2 4 4
输出 #2

                            
输入 #3
1 1 200 200
输出 #3

                            
C++ 编辑器
输入
输出