#abc286f. F - Guess The Number 2

F - Guess The Number 2

Score : 500500 points

问题描述

这是一个 交互式任务,你编写的程序和裁判程序将通过标准输入和输出进行交互。

你们将按照以下步骤进行操作。该过程包括阶段1和阶段2,阶段1紧接阶段2。

(阶段1)

  • 裁判决定一个整数 NN,其范围在 1110910^9(包含)之间,但这个值是隐藏的。
  • 你打印一个整数 MM,其范围在 11110110(包含)之间。
  • 你还需打印一个长度为 MM 的整数序列 A=(A1,A2,,AM)A=(A_1,A_2,\ldots,A_M),其中对于所有 i=1,2,,Mi = 1, 2, \ldots, M,满足 1AiM1 \leq A_i \leq M

(阶段2)

  • 裁判给你一个长度为 MM 的整数序列 B=(B1,B2,,BM)B=(B_1,B_2,\ldots,B_M)。这里,Bi=fN(i)B_i = f^N(i)。函数 f(i)f(i) 定义为对于所有在 11MM(包含)之间的整数 ii,都有 f(i)=Aif(i)=A_i,而 fN(i)f^N(i) 是通过将 ii 替换为 f(i)f(i) 连续进行 NN 次后得到的整数。
  • 根据给出的 BB 序列,你需要识别出裁判所决定的整数 NN,并打印出 NN

完成上述步骤后,请立即终止程序以接受正确性判断。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

This is an interactive task, where your and the judge's programs interact via Standard Input and Output.

You and the judge will follow the procedure below. The procedure consists of phases 11 and 22; phase 11 is immediately followed by phase 22.

(Phase 11)

  • The judge decides an integer NN between 11 and 10910^9 (inclusive), which is hidden.
  • You print an integer MM between 11 and 110110 (inclusive).
  • You also print an integer sequence A=(A1,A2,,AM)A=(A_1,A_2,\ldots,A_M) of length MM such that 1AiM1 \leq A_i \leq M for all i=1,2,,Mi = 1, 2, \ldots, M.

(Phase 22)

  • The judge gives you an integer sequence B=(B1,B2,,BM)B=(B_1,B_2,\ldots,B_M) of length MM. Here, Bi=fN(i)B_i = f^N(i). f(i)f(i) is defined by f(i)=Aif(i)=A_i for all integers ii between 11 and MM (inclusive), and fN(i)f^N(i) is the integer resulting from replacing ii with f(i)f(i) NN times.
  • Based on the given BB, you identify the integer NN that the judge has decided, and print NN.

After the procedure above, terminate the program immediately to be judged correct.

Constraints

  • NN is an integer between 11 and 10910^9 (inclusive).

Input and Output

This is an interactive task, where your and the judge's programs interact via Standard Input and Output.

(Phase 11)

  • First, print an integer MM between 11 and 110110 (inclusive). It must be followed by a newline.

MM

  • Then, print a sequence A=(A1,A2,,AM)A=(A_1,A_2,\ldots,A_M) of length MM consisting of integers between 11 and MM (inclusive), with spaces in between. It must be followed by a newline.

A1A_1 A2A_2 \ldots AMA_M

(Phase 22)

  • First, an integer sequence B=(B1,B2,,BM)B=(B_1,B_2,\ldots,B_M) of length MM is given from the input.

B1B_1 B2B_2 \ldots BMB_M

  • Find the integer NN and print it. It must be followed by a newline.

NN

If you print something illegal, the judge prints -1. In that case, your submission is already considered incorrect. Since the judge program terminates at this point, it is desirable that your program terminates too.

Notes

  • After each output, add a newline and then flush Standard Output. Otherwise, you may get a TLE verdict.
  • If an invalid output is printed during the interaction, or if the program terminates halfway, the verdict will be indeterminate.
  • After you print the answer (or you receive -1), immediately terminate the program normally. Otherwise, the verdict will be indeterminate.
  • Note that an excessive newline is also considered an invalid input.

Sample Interaction

The following is a sample interaction with N=2N = 2.

InputOutputDescription
The judge has decided that $N=2$. $N$ is hidden: it is not given as an input.
4You print $M$.
2 3 4 4You print $A=(2,3,4,4)$.
3 4 4 4$f^2(1)=3,f^2(2)=4,f^2(3)=4$, and $f^2(4)=4$, so the judge gives $B=(3,4,4,4)$ to your program.
2Based on $B$, you have identified that $N=2$. Print $N$ and terminate the program normally.

update @ 2024/3/10 11:58:26