#P9916. 「RiOI-03」Just a Q. (Easy ver.)

    ID: 10278 远端评测题 1200ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>数学二分洛谷原创交互题Special JudgeO2优化洛谷月赛Ad-hoc

「RiOI-03」Just a Q. (Easy ver.)

Background

“Yes, I am Q.”

Little R smiled.

  • It is guaranteed that any reasonable partial solution or full solution with std + spj for this problem can run correctly and get AC under the current testdata within the time limit of 400400 ms and the memory limit of 3232 MB.
  • This problem does not add hack testdata that is only meant to meaninglessly max out the spj running time.

Please note that this problem differs from the hard version only in the constraints, and the constraints of the two versions do not completely overlap.

Problem Description

This is an interactive problem.

Little R has a variable QQ. Initially, Q=0Q = 0.

Little R has nn hidden integers q1qnq_1 \dots q_n, satisfying 1qiV1 \leq \lvert q_i \rvert \leq V, and there exists exactly one index ii such that qi<0q_i \lt 0. You need to determine this index ii with qi<0q_i \lt 0.

Little R promises she will not make you blindly guess with only probability 1n\frac{1}{n}, so she allows you to make at most kk queries. In each query, you may give Little R a multiset SS of positive integers satisfying 0SSmax0 \leq \lvert S \rvert \leq S_{\max} and iS,in\forall i \in S, i \leq n. She will compute M=iSqiM = \prod\limits_{i\in S} q_i, then update QQ+MQ \leftarrow Q + M. In particular, if SS is empty, then M=1M = 1.

After one query, Little R will tell you the current sgn(Q)\text{sgn}(Q) (which is +, -, or 0), i.e., the sign of QQ. Specifically, if Q>0Q \gt 0, she returns +; if Q<0Q \lt 0, she returns -; otherwise she returns 0.

You must find the index ii such that qi<0q_i \lt 0 within at most kk queries.

It is guaranteed that for all testdata, the index ii with qi<0q_i \lt 0 is chosen uniformly at random in [1,n][1, n]. Please note that reporting the index counts as one query.

Input Format

Interactive Protocol

In the first line, read three positive integers n,k,Smaxn, k, S_{\max}.

After that, you should perform several queries.

For each query, output ?\ m\ s_1\ s_2 \dots s_m, meaning you provide a multiset SS of positive integers of size mm. You must ensure 0mSmax0 \leq m \leq S_{\max}. Also, you must have 1sin1 \leq s_i \leq n, describing the indices of the elements in the set.

If you have obtained the answer, output !\ i with 1in1 \leq i \leq n, meaning you conclude qi<0q_i \lt 0. After that, you should immediately exit the current interaction round.

After each output, you must flush the buffer.

You may use the following statements to flush the buffer:

  • For C/C++: fflush(stdout);
  • For C++: std::cout << std::flush;
  • For Java: System.out.flush();
  • For Python: stdout.flush();
  • For Pascal: flush(output);
  • For other languages, please check the help documentation for your language.

In particular, for C++, if you use std::endl instead of '\n' when printing a newline, it will also flush the buffer automatically.

Each time after you query and flush the buffer, you will read one character from standard input: +, -, or 0, representing the current sign sgn(Q)\text{sgn}(Q).

Input Format

This problem contains multiple test cases.

In the first line, an integer TT indicates the number of test cases.

For each test case, interact according to [Interactive Protocol]. After you report an index:

  • If the index you give is correct:
    • If this is the last test case, the interactive library exits and returns Accepted.
    • If this is not the last test case, you should continue by reading n,k,Smaxn, k, S_{\max} to start interacting for the next test case.
  • Otherwise, if the index is wrong, the interactive library will terminate immediately and return Unaccepted.

Output Format

See [Input Format].

1
6 6 6

-

-

-

+

0





? 1 1

? 5 1 2 3 4 5

? 3 2 4 6

? 1 4

? 3 1 5 6

! 1

Hint

Sample Explanation 1

q={1,1,4,5,1,4}q = \{-1, 1, 4, 5, 1, 4\}.

Data Scale and Constraints

This problem uses bundled tests.

  • Subtask 0 (5 pts): qi1q_i \neq 1 and qi1q_i \neq -1.
  • Subtask 1 (10 pts): qi1q_i \neq -1, k=2nk = 2n.
  • Subtask 2 (10 pts): qi1q_i \neq 1, k=2nk = 2n.
  • Subtask 3 (9 pts): n=13n = 13, k=5000k = 5000.
  • Subtask 4 (11 pts): n=13n = 13, k=2500k = 2500.
  • Subtask 5 (20 pts): k=2nk = 2n.
  • Subtask 6 (35 pts): No additional constraints.

For each test case, 1n2001 \leq n \leq 200, 1V1061 \leq V \leq 10^6, nk5×103n \leq k \leq 5\times 10^3, and Smax=nS_{\max} = n.

For each test point, 1T5001 \leq T \leq 500, n22×105\sum n^2 \leq 2\times 10^5, and k2×105\sum k \leq 2\times 10^5.

Translated by ChatGPT 5