#P11109. [ROI 2023] 会议 (Day 2)

[ROI 2023] 会议 (Day 2)

Background

Translated from ROI 2023 D2T2

The Peruvian Association of Science and Education is organizing a conference and plans to hold nn activities, numbered from 11 to nn. Let lil_i and rir_i be the start and end times of activity ii, respectively. Since some activities may overlap, a person may not be able to attend all of them. Activities ii and jj are considered non-conflicting if ri<ljr_i < l_j or rj<lir_j < l_i.

A set of activities is called compatible if every two different activities in the set are non-conflicting. Suppose the maximum size of a compatible set is mm. The saturation of the conference is defined as nm\frac{n}{m}. Due to budget cuts, the organizers decided to reduce the number of conference activities by half. At the same time, they want the saturation to remain unchanged, so in the reduced set of activities, the maximum size of a compatible set must also be reduced by half.

It is guaranteed that, in the original conference plan, both the number of activities nn and the maximum compatible set size mm are even.

Problem Description

Help the organizers choose n2\frac{n}{2} activities from the plan so that the maximum size of a compatible set among the chosen activities is m2\frac{m}{2}.

Input Format

Each test contains multiple test cases.

The first line contains an integer tt, the number of test cases (1t500001 \le t \le 50000).

The first line of each test case contains an integer nn, the number of activities in the original plan (2n1000002 \le n \le 100000, and nn is even).

In the next nn lines, the activities are described. Each line contains two integers lil_i and rir_i, the start and end times of activity ii (1li<ri1091 \le l_i < r_i \le 10^9).

It is guaranteed that the maximum compatible set size mm in the original plan is even, and n100000\sum n\le100000.

Output Format

For each test case, output n2\frac{n}{2} distinct activity indices in one line, representing the activities that will be kept. If there are multiple valid answers, output any of them. The maximum size of a compatible set among the selected activities must be m2\frac{m}{2}.

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
2 5 3 4
1 2 3

Hint

Sample explanation:

The figure above shows the initial set of activities in the first test case. One possible maximum compatible set is marked with a thick dashed line.

The figure above shows the set of activities in one valid answer for the first test case. One possible maximum compatible set is marked with a thick dashed line.

The initial set of activities in the second test case.

The set of activities in one valid answer for the second test case.

Let N=nN=\sum n. We say that activity ii completely covers activity jj if and only if lilj<rjril_i\le l_j<r_j\le r_i.

Subtask Score NN\le Special Properties
11 55 100000100000 Any two activities are non-conflicting.
22 2020
33 77 3030
44 1515 500500 For any two activities ii and jj, they are either non-conflicting, or one completely covers the other; and there is an activity that completely covers all other activities.
55 100000100000 For any two activities ii and jj, they are either non-conflicting, or one completely covers the other.
66 1313 500500
77 50005000
88 1212 100000100000

Translated by ChatGPT 5