QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#10259. 极角排序

الإحصائيات

给定平面上的 $n$ 个整点,第 $i$ ($1 \le i \le n$) 个点的坐标为 $(x_i, y_i)$。

你需要将所有点按照 $\text{atan2}(y_i, x_i)$ 进行排序,也即从 $x$ 轴负半轴(不含)开始进行逆时针排序。

你需要注意的是:

  • $\text{atan2}(0, 0) = 0$
  • $\text{atan2}(0, x) = \pi\;(\forall x < 0)$

如果两个点的极角相同,你可以将极角相同的点按照任意顺序排序。

输入格式

输入的第一行包含一个整数 $n$ ($1 \le n \le 2 \cdot 10^5$)。

接下来一行,包含 $n$ 个整数 $x_i$, $y_i$ ($-10^{18} \le x_i, y_i \le 10^{18}$)。

输出格式

输出包含一行 $n$ 个整数 $p_1, p_2, \ldots, p_n$ ($1 \le p_i \le n$, $p_i$ 互不相同),描述你的排序。

样例数据

样例输入

9
-1 0
0 0
0 -1
-1 -1
1 1
1 -1
-1 1
1 0
0 1

样例输出

4 3 6 2 8 5 9 7 1

子任务

  • Subtask 1 (10 points): $|x_i|, |y_i| \le 10^4$
  • Subtask 2 (20 points): $|x_i|, |y_i| \le 10^9$
  • Subtask 3 (70 points): No additional constraints.
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.