Time limit: 0.5 seconds. Memory limit: 128 MiB. See the reference environment and measurements.
An archive hides an ordered row of labels. A terminal compares a submitted label sequence with the hidden row and returns the longest contiguous match. Recover the row using a limited number of comparisons.
(This story was rewritten by GPT-6.)
This is an interactive problem. Before interaction starts, the judge fixes a permutation
You may query a sequence
Use at most 800 queries, then report the entire permutation. The final report does not count as a query.
Your program first reads
Print a query as ? k q_1 ... q_k on one line. Print the final answer as ! p_1 ... p_n and exit. Flush after each line. Invalid lengths, values, syntax, or query counts, and an incorrect final permutation, fail.
The samples below are local-judge fixtures: each input file contains std.cpp . See the local testing guide.
1
1
1
4
2 1 4 3
2 1 4 3
3
3 2 1
3 2 1
Sample 2 hides ? 5 1 2 1 4 1 receives 3 because the contiguous block ! 2 1 4 3 .
A query repeating pivot 1 tests whether candidate labels are adjacent to 1; matches are contiguous and directed.
Specifications redesigned by Codex (GPT-6): the text protocol, flushing and termination rules, and the local hidden-data format.
| Score | Additional constraints |
|---|---|
| 20% | |
| 30% | |
| 50% | No additional constraints |