CF1807E.Interview

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

This is an interactive problem. If you are unsure how interactive problems work, then it is recommended to read the guide for participants.

Before the last stage of the exam, the director conducted an interview. He gave Gon nn piles of stones, the ii -th pile having aia_i stones.

Each stone is identical and weighs 11 grams, except for one special stone that is part of an unknown pile and weighs 22 grams.

A picture of the first test case. Pile 22 has the special stone. The piles have weights of 1,3,3,4,51,3,3,4,5 , respectively.Gon can only ask the director questions of one kind: he can choose kk piles, and the director will tell him the total weight of the piles chosen. More formally, Gon can choose an integer kk ( 1kn1 \leq k \leq n ) and kk unique piles p1,p2,,pkp_1, p_2, \dots, p_k ( 1pin1 \leq p_i \leq n ), and the director will return the total weight mp1+mp2++mpkm_{p_1} + m_{p_2} + \dots + m_{p_k} , where mim_i denotes the weight of pile ii .

Gon is tasked with finding the pile that contains the special stone. However, the director is busy. Help Gon find this pile in at most 30\mathbf{30} queries.

输入格式

The input data contains several test cases. The first line contains one integer tt ( 1t10001 \leq t \leq 1000 ) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn ( 1n21051 \leq n \leq 2 \cdot 10^5 ) — the number of piles.

The second line of each test case contains nn integers aia_i ( 1ai1041 \leq a_i \leq 10^4 ) — the number of stones in each pile.

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5 .

After reading the input for each test case, proceed with the interaction as follows.

输出格式

You can perform the operation at most 30\mathbf{30} times to guess the pile.

To make a guess, print a line with the following format:

  • ? k p1 p2 p3 ... pk1 pk\texttt{?}\ k \ p_1 \ p_2 \ p_3 \ ... \ p_{k-1}\ p_k ( 1kn1 \leq k \leq n ; 1pin1 \leq p_i \leq n ; all pip_i are distinct) — the indices of the piles.

After each operation, you should read a line containing a single integer xx — the sum of weights of the chosen piles. (Formally, x=mp1+mp2++mpkx = m_{p_1} + m_{p_2} + \dots + m_{p_k} .)When you know the index of the pile with the special stone, print one line in the following format: ! m\texttt{!}\ m ( 1mn1 \leq m \leq n ).

After that, move on to the next test case, or terminate the program if there are no more test cases remaining.

If your program performs more than 3030 operations for one test case or makes an invalid query, you may receive a Wrong Answer verdict.

After you print a query or the answer, please remember to output the end of the line and flush the output. Otherwise, you may get Idleness limit exceeded or some other verdict. To do this, use the following:

  • 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.

It is additionally recommended to read the interactive problems guide for participants.

Hacks

To make a hack, use the following format.

The first line should contain a single integer tt ( 1t10001 \leq t \leq 1000 ) — the number of test cases.

The first line of each test case should contain two integers n,mn, m ( 1n21051 \leq n \leq 2 \cdot 10^5 ) – the number of piles and the pile with the special stone.

The second line of each test case should contain nn integers aia_i ( 1ai1041 \leq a_i \leq 10^4 ) — the number of stones in each pile.

Note that the interactor is not adaptive, meaning that the answer is known before the participant asks the queries and doesn't depend on the queries asked by the participant.

输入输出样例

  • 输入#1

    2
    5
    1 2 3 4 5
    
    11
    
    6
    
    3
    
    7
    1 2 3 5 3 4 2
    
    12
    
    6

    输出#1

    ? 4 1 2 3 4
    
    ? 2 2 3
    
    ? 1 2
    
    ! 2
    
    ? 4 2 3 5 6
    
    ? 2 1 4
    
    ! 7

说明/提示

In the first test case, the stone with weight two is located in pile 22 , as shown in the picture. We perform the following interaction:

  • ? 4 1 2 3 4\texttt{? 4 1 2 3 4} — ask the total weight of piles 11 , 22 , 33 , and 44 . The total weight we receive back is 1+3+3+4=111+3+3+4=11 .
  • ? 2 2 3\texttt{? 2 2 3} — ask the total weight of piles 22 and 33 . The total weight we receive back is 3+3=63+3=6 .
  • ? 1 2\texttt{? 1 2} — ask the total weight of pile 22 . The total weight we receive back is 33 .
  • ! 2\texttt{! 2} — we have figured out that pile 22 contains the special stone, so we output it and move on to the next test case.

In the second test case, the stone with weight two is located on index 77 . We perform the following interaction:

  • ? 4 2 3 5 6\texttt{? 4 2 3 5 6} — ask the total weight of piles 22 , 33 , 55 , and 66 . The total weight we receive back is 2+3+3+4=122+3+3+4=12 .
  • ? 2 1 4\texttt{? 2 1 4} — ask the total weight of piles 11 and 44 . The total weight we receive back is 1+5=61+5=6 .
  • ! 7\texttt{! 7} — we have somehow figured out that pile 77 contains the special stone, so we output it and end the interaction.
首页