QOJ.ac

QOJ

حد الوقت: 1.0 s حد الذاكرة: 512 MB مجموع النقاط: 100

#8907. Conference

الإحصائيات

The Tyumen Association of Scientific and Educational Communities is organizing a conference, within which it was planned to hold $n$ events, numbered from $1$ to $n$. Each $i$-th event is defined by two integers $l_i$ and $r_i$ — the start and end times of the event.

Since some events may overlap or even coincide completely in time, one person cannot always attend all the conference events. We consider events $i$ and $j$ to be non-overlapping if $r_i < l_j$ or $r_j < l_i$.

A set of events is called compatible if any two distinct events in this set do not overlap. Let the maximum size of a compatible set of events at the conference be $m$. We call the ratio $n/m$ the saturation of the conference.

Due to budget cuts, the conference organizers have decided that the number of events at the conference will be reduced by exactly half. At the same time, they want to keep the saturation of the conference unchanged, so the maximum size of a compatible set of events within the conference must also decrease by exactly half. It turned out that in the original conference plan, both the number of events $n$ and the maximum possible number of events in a compatible set $m$ are even numbers.

Help the organizers choose a set of $n/2$ originally planned events to be held such that the size of the maximum compatible set of the chosen events is equal to $m/2$.

Input

One test contains several input datasets. The first line contains a single integer $t$ — the number of input datasets ($1 \le t \le 50\,000$). The first line of each dataset description contains a single integer $n$ — the number of events in the original plan ($2 \le n \le 100\,000$, $n$ is even). The next $n$ lines of each dataset description contain the description of the events. The $i$-th line contains two integers $l_i$ and $r_i$ — the start and end time of the $i$-th event ($1 \le l_i < r_i \le 10^9$). It is guaranteed that $m$, the size of the maximum compatible set of events for the original plan, is even.

Output

For each input dataset, output on a new line $n/2$ distinct event numbers that should be held. If there are several suitable answers, you may output any of them. For the conducted events, the size of the maximum compatible set of events must be equal to $m/2$.

Subtasks

Let $N$ be the sum of $n$ over all input datasets in one test. We say that event $i$ covers event $j$ if $l_i \le l_j < r_j \le r_i$.

Subtask Points $N$ Additional Constraints Required Subtasks
1 5 $N \le 100\,000$ Any two events do not overlap
2 20 $N \le 20$ 1
3 7 $N \le 30$ 1, 2
4 15 $N \le 500$ In every pair of events, either one event covers the other, or they do not overlap; there exists an event that covers all others
5 15 $N \le 100\,000$ In every pair of events, either one event covers the other, or they do not overlap 1, 4
6 13 $N \le 500$ 1, 2–4
7 13 $N \le 5\,000$ 1, 2–4, 6
8 12 $N \le 100\,000$ 1, 1–7

Examples

Input 1

2
8
12 14
1 3
2 4
1 10
5 6
7 9
8 10
11 13
6
1 2
2 4
1 2
1 4
5 7
6 8

Output 1

2 5 3 4
1 2 3

Note

The figures visualize the events. An event starting at time $l_i$ and ending at time $r_i$ is depicted as a segment $[l_i, r_i]$.

Fig. 1: Original set of events in the first input dataset of the example. One of the possible maximum compatible sets is highlighted with a bold dashed line.

Fig. 2: Set of events corresponding to the answer for the first input dataset in the example. One of the possible maximum compatible sets is highlighted with a bold dashed line.

Fig. 3: Original set of events in the second input dataset of the example. One of the possible maximum compatible sets is highlighted with a bold dashed line.

Fig. 4: Set of events corresponding to the answer for the second input dataset in the example. One of the possible maximum compatible sets is highlighted with a bold dashed line.

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.