Universal Cup Judging System

Universal Cup

时间限制: 2.0 s 内存限制: 1024 MB 总分: 100 可 Hack ✓
统计

二次元平面上に $N$ 個の点 $p_1, p_2, \dots, p_N$ があります。

点 $p_i$ は $(X_i, Y_i)$ に位置しています。どの2つの点も同じ座標を共有しません。

点の列 $p = (p_1, p_2, \dots, p_N)$ の順列 $q = (q_1, q_2, \dots, q_N)$ であって次の条件を満たすものを1つ構築するか、それが不可能であると判定してください。

  • すべての $1 \le i \le N - 2$ について、3つの点 $q_i, q_{i+1}, q_{i+2}$ はこの順に一直線上にあるか、反時計回りに曲がっている。
    • より正確には、$q_i$ の座標を $(x_i, y_i)$ とするとき、次が成り立たなければならない: $(x_{i+1} - x_i)(y_{i+2} - y_{i+1}) - (y_{i+1} - y_i)(x_{i+2} - x_{i+1}) \ge 0$。

$T$ 個のテストケースについてこの問題を解いてください。

入力

入力は以下の形式で与えられます:

T
case1
case2
:
caseT

各テストケースは以下の形式で与えられます:

N
X1 Y1
X2 Y2
:
XN YN
  • $1 \le T \le 100$
  • $3 \le N \le 3000$
  • $0 \le X_i, Y_i \le 10^9$
  • $(X_i, Y_i) \ne (X_j, Y_j)$($i \ne j$)
  • すべてのテストケースにおける $N$ の総和は $3000$ を超えない
  • 入力される値はすべて整数である

出力

$T$ 行出力してください。

$i$ 行目には、$i$ 番目のテストケースにおいて条件を満たす $q$ が存在しない場合、$-1$ を出力してください。

そうでない場合、$q = (p_{r_1}, p_{r_2}, \dots, p_{r_N})$ としたとき、$r_1, r_2, \dots, r_N$ をこの順に空白区切りで出力してください。

条件を満たす答えが複数存在する場合は、そのうちのどれを出力しても構いません。

入出力例

入力例 1

1
9
2 4
2 3
2 2
1 1
4 4
4 3
5 2
5 1
6 5

出力例 1

6 9 2 3 5 1 8 7 4

注記

problem_17421_1.png

図 1:入出力例の説明。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1485EditorialOpen题解jianglyView
#1343EditorialOpen题解MilmonView

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.