CF1477C.Nezzar and Nice Beatmap

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Nezzar loves the game osu!.

osu! is played on beatmaps, which can be seen as an array consisting of distinct points on a plane. A beatmap is called nice if for any three consecutive points A,B,CA,B,C listed in order, the angle between these three points, centered at BB, is strictly less than 9090 degrees.

Points A,B,CA,B,C on the left have angle less than 9090 degrees, so they can be three consecutive points of a nice beatmap; Points A′,B′,C′A',B',C' on the right have angle greater or equal to 9090 degrees, so they cannot be three consecutive points of a nice beatmap.

Now Nezzar has a beatmap of nn distinct points A1,A2,…,AnA_1,A_2,\ldots,A_n. Nezzar would like to reorder these nn points so that the resulting beatmap is nice.

Formally, you are required to find a permutation p1,p2,…,pnp_1,p_2,\ldots,p_n of integers from 11 to nn, such that beatmap Ap1,Ap2,…,ApnA_{p_1},A_{p_2},\ldots,A_{p_n} is nice. If it is impossible, you should determine it.

Nezzar 非常喜爱游戏 osu!。

osu! 在“谱面”(beatmap)上进行,而谱面可视为平面上由若干互异点构成的一个数组。若对谱面中任意三个按顺序排列的连续点 A,B,CA,B,C,以 BB 为顶点所形成的夹角严格小于 90∘90^\circ,则称该谱面是“优美的”(nice)。

左侧的三点 A,B,CA,B,C 所成夹角小于 90∘90^\circ,因此它们可以作为某个优美谱面中三个连续的点;右侧的三点 A′,B′,C′A',B',C' 所成夹角大于或等于 90∘90^\circ,因此它们不能作为任何优美谱面中三个连续的点。

现在 Nezzar 拥有一个包含 nn 个互异点 A1,A2,…,AnA_1,A_2,\ldots,A_n 的谱面。Nezzar 希望将这 nn 个点重新排序,使得所得谱面是优美的。

形式化地说,你需要找出一个 11 到 nn 的排列 p1,p2,…,pnp_1,p_2,\ldots,p_n,使得重排后的谱面 Ap1,Ap2,…,ApnA_{p_1},A_{p_2},\ldots,A_{p_n} 是优美的。若不存在这样的排列,则需判定其不可能性。

输入格式

The first line contains a single integer nn (3≤n≤50003 \le n \le 5000).

Then nn lines follow, ii-th of them contains two integers xix_i, yiy_i (−109≤xi,yi≤109-10^9 \le x_i, y_i \le 10^9) — coordinates of point AiA_i.

It is guaranteed that all points are distinct.

第一行包含一个整数 nn(3≤n≤50003 \le n \le 5000)。

接下来是 nn 行,其中第 ii 行包含两个整数 xix_i、yiy_i(−109≤xi,yi≤109-10^9 \le x_i, y_i \le 10^9),表示点 AiA_i 的坐标。

保证所有点互不相同。

输出格式

If there is no solution, print −1-1.

Otherwise, print nn integers, representing a valid permutation pp.

If there are multiple possible answers, you can print any.

如果没有解,输出 −1-1。

否则,输出 nn 个整数,表示一个合法的排列 pp。

如果存在多个可能的答案,输出任意一个即可。

输入输出样例

  • 输入#1

    5
    0 0
    5 0
    4 2
    2 1
    3 0

    输出#1

    1 2 5 3 4

说明/提示

Here is the illustration for the first test:

Please note that the angle between A1A_1, A2A_2 and A5A_5, centered at A2A_2, is treated as 00 degrees. However, angle between A1A_1, A5A_5 and A2A_2, centered at A5A_5, is treated as 180180 degrees.

第一个测试用例的示意图如下:

请注意:以 A2A_2 为顶点、由 A1A_1、A2A_2 和 A5A_5 构成的角被视为 0∘0^\circ;而以 A5A_5 为顶点、由 A1A_1、A5A_5 和 A2A_2 构成的角被视为 180∘180^\circ。

输入解题思路,AI测评打分。不知道怎么写?

首页