QOJ.ac

QOJ

Límite de tiempo: 4 s Límite de memoria: 512 MB Puntuación total: 100 Interactivo

#6345. 随机交互式凸包机器人

Estadísticas

一组 $n$ 个点是从所有坐标不超过 $10^9$ 的正整数且大小为 $n$ 的二维点集中均匀随机选取的,满足任意三点不共线。你的任务是找到它们的凸包。但你并不知道这些点的坐标。相反,你可以进行形如 “? i j k” 的查询,评测程序会返回 $1$(如果从 $\vec{P_iP_j}$ 到 $\vec{P_iP_k}$ 的转向是逆时针的)或 $-1$(如果转向是顺时针的)。你可以将其理解为 $\text{sgn}(\vec{P_iP_j} \times \vec{P_iP_k})$,其中 $\times$ 表示叉积。当你认为自己已经确定了凸包时,请输出 “! k i_1 i_2 \dots i_k”,其中 $k$ 是凸包的大小,$i_1, i_2, \dots, i_k$ 是凸包上点的索引,按逆时针顺序排列。任意点都可以作为第一个点。数据范围:$3 \le n \le 5000$,你最多可以进行 $30\,000$ 次查询。

交互

首先读取 $n$ ($3 \le n \le 5000$)。

然后开始进行查询,输出 “? i j k” ($1 \le i, j, k \le n$,且 $\{i, j, k\}$ 互不相同)。每次查询后读取响应,响应为 $1$ 或 $-1$。你最多可以进行 $30\,000$ 次查询。

请记得刷新输出。不要进行无效查询,否则可能会导致奇怪的判题结果。

在完成所有查询后,输出答案 “! k i_1 i_2 \dots i_k”,其中 $k$ 是凸包的大小,$i_1, i_2, \dots, i_k$ 是凸包上点的索引,按逆时针顺序排列。这不计入查询次数。

保证点集是从所有坐标不超过 $10^9$ 的正整数且大小为 $n$ 的二维点集中均匀随机选取的,满足任意三点不共线。点的顺序也是均匀随机的。交互器是非自适应的。

样例

输入 1

5
1
-1
1
-1
-1
-1
1

输出 1

? 3 1 4
? 3 5 1
? 3 4 5
? 1 5 4
? 2 3 1
? 2 4 3
? 2 4 5
! 4 1 4 5 2

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.