#P9916. 「RiOI-03」Just a Q. (Easy ver.)
「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 ms and the memory limit of 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 . Initially, .
Little R has hidden integers , satisfying , and there exists exactly one index such that . You need to determine this index with .
Little R promises she will not make you blindly guess with only probability , so she allows you to make at most queries. In each query, you may give Little R a multiset of positive integers satisfying and . She will compute , then update . In particular, if is empty, then .
After one query, Little R will tell you the current (which is +, -, or 0), i.e., the sign of . Specifically, if , she returns +; if , she returns -; otherwise she returns 0.
You must find the index such that within at most queries.
It is guaranteed that for all testdata, the index with is chosen uniformly at random in . Please note that reporting the index counts as one query.
Input Format
Interactive Protocol
In the first line, read three positive integers .
After that, you should perform several queries.
For each query, output ?\ m\ s_1\ s_2 \dots s_m, meaning you provide a multiset of positive integers of size . You must ensure . Also, you must have , describing the indices of the elements in the set.
If you have obtained the answer, output !\ i with , meaning you conclude . 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 .
Input Format
This problem contains multiple test cases.
In the first line, an integer 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 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
.
Data Scale and Constraints
This problem uses bundled tests.
- Subtask 0 (5 pts): and .
- Subtask 1 (10 pts): , .
- Subtask 2 (10 pts): , .
- Subtask 3 (9 pts): , .
- Subtask 4 (11 pts): , .
- Subtask 5 (20 pts): .
- Subtask 6 (35 pts): No additional constraints.
For each test case, , , , and .
For each test point, , , and .
Translated by ChatGPT 5