102865: [AtCoder]ABC286 F - Guess The Number 2

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

Description

Score : $500$ points

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 $1$ and $2$; phase $1$ is immediately followed by phase $2$.

(Phase $1$)

  • The judge decides an integer $N$ between $1$ and $10^9$ (inclusive), which is hidden.
  • You print an integer $M$ between $1$ and $110$ (inclusive).
  • You also print an integer sequence $A=(A_1,A_2,\ldots,A_M)$ of length $M$ such that $1 \leq A_i \leq M$ for all $i = 1, 2, \ldots, M$.

(Phase $2$)

  • The judge gives you an integer sequence $B=(B_1,B_2,\ldots,B_M)$ of length $M$. Here, $B_i = f^N(i)$. $f(i)$ is defined by $f(i)=A_i$ for all integers $i$ between $1$ and $M$ (inclusive), and $f^N(i)$ is the integer resulting from replacing $i$ with $f(i)$ $N$ times.
  • Based on the given $B$, you identify the integer $N$ that the judge has decided, and print $N$.

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

Constraints

  • $N$ is an integer between $1$ and $10^9$ (inclusive).

Input and Output

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

(Phase $1$)

  • First, print an integer $M$ between $1$ and $110$ (inclusive). It must be followed by a newline.
$M$
  • Then, print a sequence $A=(A_1,A_2,\ldots,A_M)$ of length $M$ consisting of integers between $1$ and $M$ (inclusive), with spaces in between. It must be followed by a newline.
$A_1$ $A_2$ $\ldots$ $A_M$

(Phase $2$)

  • First, an integer sequence $B=(B_1,B_2,\ldots,B_M)$ of length $M$ is given from the input.
$B_1$ $B_2$ $\ldots$ $B_M$
  • Find the integer $N$ and print it. It must be followed by a newline.
$N$

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

Input

题意翻译

你需要构造一个长为 $m (1\leq m \leq 110) $ 的序列 $A (1\leq a_i\leq m)$ 并将其输出,交互库会返回序列 $B$ 满足 $b_i=f^N(i)(1\le i\le m)$(其中 $f^1(i)=a_i$,$f^N(i)=f(f^{N-1}(i))(N>1)$),然后请你根据序列 $B$ 得到正确的 $N$。

Output

得分:500分

问题描述

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

你和裁判将遵循以下程序。 程序由阶段$1$和阶段$2$组成;阶段$1$紧接着阶段$2$。

(阶段$1$)

  • 裁判在$1$到$10^9$(含)之间决定一个隐藏的整数$N$。
  • 你打印一个在$1$到$110$(含)之间的整数$M$。
  • 你还打印一个长度为$M$的整数序列$A=(A_1,A_2,\ldots,A_M)$,其中对于所有$i = 1, 2, \ldots, M$,都有$1 \leq A_i \leq M$。

(阶段$2$)

  • 裁判给你一个长度为$M$的整数序列$B=(B_1,B_2,\ldots,B_M)$。在这里,$B_i = f^N(i)$。$f(i)$对于在$1$和$M$(含)之间的所有整数$i$定义为$f(i)=A_i$,$f^N(i)$是将$i$替换为$f(i)$的$N$次的结果。
  • 根据给定的$B$,你识别裁判决定的整数$N$,并打印$N$。

在上述程序后,立即终止程序以被判断为正确。

约束

  • $N$是一个在$1$到$10^9$(含)之间的整数。

输入和输出

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

(阶段$1$)

  • 首先,打印一个在$1$到$110$(含)之间的整数$M$。后面必须跟一个换行符。
$M$
  • 然后,打印一个长度为$M$的整数序列$A=(A_1,A_2,\ldots,A_M)$,其中每个元素都在$1$到$M$(含)之间,元素之间用空格隔开。后面必须跟一个换行符。
$A_1$ $A_2$ $\ldots$ $A_M$

(阶段$2$)

  • 首先,从输入中给出长度为$M$的整数序列$B=(B_1,B_2,\ldots,B_M)$。
$B_1$ $B_2$ $\ldots$ $B_M$
  • 找到整数$N$并打印它。后面必须跟一个换行符。
$N$

如果你打印了非法内容,裁判将打印-1。在这种情况下,你的提交已经被认为是错误的。由于裁判程序在这一点上终止,所以你的程序也最好终止。

注意

  • 每次输出后,添加一个换行符,然后冲洗标准输出。 否则,你可能会得到一个

加入题单

算法标签: