QOJ.ac

QOJ

حد الوقت: 2.0 s حد الذاكرة: 256 MB مجموع النقاط: 100 تفاعلية

#8882. 秘密排列

الإحصائيات

这是一个交互式问题。

存在一个从 $0$ 到 $n-1$ 的整数的秘密排列 $p$。该排列从 $0$ 开始索引。 你需要通过询问形如 “? $a_i$ $b_i$ $c_i$” 的问题来猜出它(其中 $a_i, b_i$ 和 $c_i$ 是 $0$ 到 $n-1$ 之间的整数)。 对于每个这样的问题,你将得到一个数字作为响应,该数字等于 $p^{-1}(p(a_i) \cdot p(b_i) + p(c_i))$(所有运算均在模 $n$ 意义下进行,且 $p^{-1}(x)$ 是满足 $p(y) = x$ 的 $y$)。最后,你需要以 “! $p(0)$ $p(1)$ ... $p(n-1)$” 的格式输出猜出的排列。

输入

输入仅包含一行,为一个整数 $n$ ($1 \le n \le 5 \cdot 10^3$)。

在每个测试中,排列在比赛前已固定,且在猜测过程中不会改变。

对于每个测试,长度 $n$ 由评测组选定,但排列随后使用伪随机数生成器生成。然而,该问题存在适用于所有可能排列的确定性解法。

交互

你可以询问零个或多个问题,并在最后进行且仅进行一次猜测。请将每个查询打印在单独的一行上,并记得刷新输出缓冲区。包括最终猜测在内,允许的最大查询次数为 $12\,512$。

样例

输入 1

4

输出 1

? 1 2 3
? 0 3 3
? 0 0 1
! 2 0 3 1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.