Universal Cup Judging System

Universal Cup

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

2차원 평면 위에 $N$개의 점 $p_1, p_2, \dots, p_N$이 있습니다.

점 $p_i$는 $(X_i, Y_i)$에 위치해 있습니다. 어떤 두 점도 같은 좌표를 공유하지 않습니다.

점들의 수열 $p = (p_1, p_2, \dots, p_N)$의 순열 $q = (q_1, q_2, \dots, q_N)$ 중 다음 조건을 만족하는 것을 하나 구성하거나, 불가능하다고 판단하세요.

  • 모든 $1 \le i \le N - 2$에 대하여, 세 점 $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.