QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#15221. Goose Goose Duck

統計

Iris has $n$ friends who like to play Goose Goose Duck, numbered $1$ to $n$.

During the holidays, everyone often asks in the group chat if anyone wants to play Goose Goose Duck and reports the number of people who have already joined. However, each person has their own thoughts on whether to join the game based on the current number of participants.

Specifically, for the $i$-th person, if the number of people who have already joined the game is in the range $[l_i, r_i]$, they will be willing to join the game.

You believe that the more people who participate in the game, the more interesting the game will be, so you decide to arrange an order for everyone to join, such that the number of people who join the game is maximized.

Input

The first line contains an integer $n$ ($1 \le n \le 10^6$), representing the total number of people.

The next $n$ lines each contain two space-separated integers $l_i, r_i$ ($0 \le l_i, r_i \le 10^6$), with meanings as described in the problem statement.

Output

The first line contains a non-negative integer $m$, representing the maximum number of people who can join the game.

The next line contains $m$ space-separated integers, where the $i$-th number is $p_i$, representing the $i$-th person to join the game.

If there are multiple ways to arrange the order, you may output any one of them.

Examples

Input 1

5
2 5
4 4
0 2
0 2
1 4

Output 1

5
4 3 5 1 2

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.