409223: GYM103463 C Hoogle Machine Translation

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Hoogle Machine Translationtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

This is an interactive problem. You have to use a flush operation right after printing each line. For example, in C++ you should use the function fflush(stdout), in Java — System.out.flush(), in Pascal — flush(output) and in Python — sys.stdout.flush().

Excellent! pubfso was lucky enough to get a Hoogle Machine Translation Machine.

This is the manual of the Hoogle Machine Translation Machine:

  • If you send a word to the machine, it will return the meaning of the word to you.
  • If you send two or more words to the machine, i.e. you send $$$x$$$ words to the machine, it will return $$$x$$$ explanations to you. Unfortunately, These $$$x$$$ explanations and $$$x$$$ words do not correspond one-to-one.

    For instance, if we have the correspondence between the following words and explanations:

    • one corresponds to $$$1$$$
    • two corresponds to $$$2$$$
    • three corresponds to $$$3$$$

    If we send $$$\{one, two, three\}$$$ to the Hoogle Machine Translation Machine.

    We may get the one of the following results:

    • $$$\{1, 2, 3\}$$$
    • $$$\{1, 3, 2\}$$$
    • $$$\{2, 1, 3\}$$$
    • $$$\{2, 3, 1\}$$$
    • $$$\{3, 1, 2\}$$$
    • $$$\{3, 2, 1\}$$$

Now, pubfso has $$$n$$$ different words need to translate, he wants your help.

Initially, pubfso will give you $$$n$$$ words.

You can make queries to the Hoogle Machine Translation Machine, Each query is a single line contains $$$x(1 \leq x \leq n)$$$ words which pubfso need to translate. Flush output stream after printing each query. Hoogle Machine Translation Machine will return $$$x$$$ explanations to you.

Your program is allowed to make no more than $$$25$$$ queries (not including printing the answer) to the Hoogle Machine Translation Machine.

Input

The first line contains a single integer $$$n(1 \leq n \leq 10^5)$$$ denoting the number of words which pubfso need to translate.

In the next line, contains $$$n$$$ strings $$$word_i$$$, denoting the $$$i$$$ th word which need to translate.

It is guaranteed that words and explanations are composed of letters or numbers, and the length does not exceed $$$10$$$.

Interaction

When your program ask the meaning of words, i.e. you need to ask $$$x(x > 0)$$$ words, print string:

"? $$$x$$$ $$$word_1$$$ $$$word_2$$$ $$$word_3$$$ $$$\cdots$$$ $$$word_x$$$"(without quotes).

What you need to focus on is, the query "? 0" is invalid, and the jury will return Wrong Answer to you.

If your query is legal, the Hoogle Machine Translation Machine will return Same number of explanations as words to you. As follows:

$$$explanation_1$$$ $$$explanation_2$$$ $$$explanation_3$$$ $$$\cdots$$$ $$$explanation_x$$$

If we answer with $$$-1$$$ instead of a valid answer, that means you exceeded the number of queries or made an invalid query.

Exit immediately after receiving $$$-1$$$ and you will see wrong answer verdict. Otherwise, you can get an arbitrary verdict because your solution will continue to read from a closed stream.

When you got the explanation of all the words, you need to print them in order. i.e. print the string:

"! $$$word_1$$$ $$$word_2$$$ $$$word_3$$$ $$$\cdots$$$ $$$word_n$$$"(without quotes).

After printing a query or printing the answer, 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 the documentation for other languages.
ExampleInput
3
one two three

1

2

3
Output
? 1 one

? 1 two

? 1 three

! 1 2 3

加入题单

上一题 下一题 算法标签: