#GL0000325. Đoán số bí mật 2 (Guess The Number 2)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Đoán số bí mật 2 (Guess The Number 2)
Guess The Number 2
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
This is an interactive problem. Your program communicates with the judge through standard input and output. Before the interaction begins, the judge chooses a hidden integer satisfying . Its value is not given directly to your program.
The interaction has exactly two phases.
Phase 1 — Specify a mapping. Choose an integer such that , then output a sequence with for every . This sequence defines a function over by .
The function need not be a permutation: repeated values in are permitted.
Phase 2 — Receive a response and guess. The judge responds with . For each index , is the result of applying exactly times starting at . Using and the mapping you selected, you must identify and print the exact hidden integer .
Terminate immediately after printing your guess. If you output invalid data, the judge may print -1 and terminate the interaction; your program must stop if it receives this signal.
Input
Initially, no value of and no ordinary input line are provided to your program.
After your program outputs and the sequence , the judge sends one line containing exactly integers , in increasing index order; every element belongs to .
The response is determined by the mapping you output and the hidden integer .
Output
First, output one line containing the integer .
Next, output one line containing exactly integers .
Flush standard output after these two lines before attempting to read the judge's response .
After reading all elements of , output one line containing your guess for , flush the output stream, and terminate.
Do not print prompts, debugging messages, or any unrelated text to standard output.
Subtasks
- Subtask 1 (20 points): The hidden integer satisfies ; your program must choose and ensure for every .
- Subtask 2 (30 points): The hidden integer satisfies ; your program must choose and ensure for every .
- Subtask 3 (50 points): The hidden integer satisfies ; your program must choose and ensure for every .
Examples
Example 1 — A sample interaction
The judge has chosen . This value is shown only to explain the example: your program does not receive as input.
Your program's first output:
4
2 3 4 4
The judge's response:
3 4 4 4
Your program's final output:
2
Explanation
The sequence defines , , , and .
Since the judge selected , each value is transformed by applying twice:
- Starting at : , hence .
- Starting at : , hence .
- Starting at : , hence .
- Starting at : , hence .
Therefore, the judge sends 3 4 4 4. Your program identifies the secret as and prints 2 to finish the interaction.
Note: This interaction only demonstrates the protocol. A correct solution for the full range up to must choose a mapping that provides enough information to distinguish all possible hidden values.