QOJ.ac

QOJ

時間限制: 6 s 記憶體限制: 2048 MB 總分: 100

#5159. 伸张正义

统计

J Justice Served

你终于做出了完美的焦糖煎饼,上面有着恰到好处的方格数量。经过一番辛苦工作,你把焦糖煎饼放在一边,离开了几秒钟去给自己倒杯热饮。满怀期待地回来时,你却发现焦糖煎饼不见了!尽管你离开的时间很短,但还是有人趁机把它偷走了。

你查看了安全监控,发现总共有 $n$ 名嫌疑人曾进入你放置焦糖煎饼的房间,每人进出房间恰好一次。看到这些后,你心里已经大概知道是谁干的了,因为你的死对头 Rob(他有一些盗窃背景)也在嫌疑人之中。但你还是想给他一个自证清白的机会,决定审问每一位嫌疑人。不出所料,每位嫌疑人都声称自己是无辜的。然而,一些嫌疑人也为其他嫌疑人提供了不在场证明。具体来说,嫌疑人 $A$ 为嫌疑人 $B$ 提供不在场证明,当且仅当 $A$ 在房间里的时间完全覆盖了 $B$ 在房间里的时间。

你觉得如果一个嫌疑人拥有由另一位同样具有说服力的嫌疑人所提供的不在场证明,那么他本人也会更有说服力。形式化地,没有不在场证明的嫌疑人其说服力为 $0$。否则,他们的说服力为所有为他们提供不在场证明的嫌疑人中,说服力最高者的说服力加 $1$。你的任务是计算每位嫌疑人的说服力。

Rob. Pixabay License by Henning on Pixabay

输入格式

输入包含:

  • 一行一个整数 $n$ ($1 \le n \le 2 \cdot 10^5$),表示嫌疑人的数量。
  • $n$ 行,每行两个整数 $a$ 和 $t$ ($1 \le a, t \le 10^9$),分别表示每位嫌疑人到达的时间和停留的时长。

保证没有两名在同一时刻到达的嫌疑人停留时长相同。

输出格式

输出每位嫌疑人的说服力。

样例

样例输入 1

4
2 8
1 7
4 5
5 2

样例输出 1

0 0 1 2

样例输入 2

5
2 4
3 3
2 2
4 2
4 1

样例输出 2

0 1 1 2 3

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.