CF1270D.Strange Device

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

This problem is interactive.

We have hidden an array aa of nn pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.

This device can answer queries of the following form: in response to the positions of kk different elements of the array, it will return the position and value of the mm -th among them in the ascending order.

Unfortunately, the instruction for the device was lost during delivery. However, you remember kk , but don't remember mm . Your task is to find mm using queries to this device.

You can ask not more than nn queries.

Note that the array aa and number mm are fixed before the start of the interaction and don't depend on your queries. In other words, interactor is not adaptive.

Note that you don't have to minimize the number of queries, and you don't need to guess array aa . You just have to guess mm .

输入格式

The first line contains two integers nn and kk ( 1k<n5001\le k < n \le 500 ) — the length of the array and the number of the elements in the query.

It is guaranteed that number mm satisfies 1mk1\le m \le k , elements a1,a2,,ana_1, a_2, \dots, a_n of the array satisfy 0ai1090\le a_i \le 10^9 , and all of them are different.

输出格式

You begin the interaction by reading nn and kk .

To ask a question about elements on positions x1,x2,,xkx_1, x_2, \dots, x_k , in a separate line output

?? x1x_1 x2x_2 x3x_3 ... xkx_k

Numbers in the query have to satisfy 1xin1 \le x_i \le n , and all xix_i have to be different. Don't forget to 'flush', to get the answer.

In response, you will receive two integers pospos and aposa_{pos} — the position in the array aa of the mm -th in ascending order element among ax1,ax2,,axka_{x_1}, a_{x_2}, \dots, a_{x_k} , and the element on this position.

In case your query is invalid or you asked more than nn queries, the program will print 1-1 and will finish interaction. You will receive a Wrong answer verdict. Make sure to exit immediately to avoid getting other verdicts.

When you determine mm , output

!! mm

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.

Hack format

For the hacks use the following format:

The first line has to contain three integers n,k,mn, k, m ( 1mk<n5001 \le m \le k < n \le 500 ) — the length of the array, number of elements in the query, and which in the ascending order number the device returns.

In the next line output nn integers a1,a2,,ana_1, a_2, \dots, a_n ( 0ai1090\le a_i \le 10^9 ) — the elements of the array. They have to be pairwise different.

输入输出样例

  • 输入#1

    4 3
    4 9
    4 9
    4 9
    1 2

    输出#1

    ? 2 3 4
    ? 1 3 4
    ? 1 2 4
    ? 1 2 3
    ! 3
    

说明/提示

In the example, n=4n = 4 , k=3k = 3 , m=3m = 3 , a=[2,0,1,9]a = [2, 0, 1, 9] .

首页