#P9925. [POI 2023/2024 R1] Zapobiegliwy student
[POI 2023/2024 R1] Zapobiegliwy student
Background
Translated from XXXI Olimpiada Informatyczna - Stage 1 Zapobiegliwy student。
Problem Description
Consider the following simple problem:
You have segments on the number line. You want to choose as many segments as possible so that they are pairwise disjoint.
I know you can do it, but you need to solve this:
You have segments on the number line. You want to choose as many pairs of segments as possible, i.e., maximize .
They must satisfy requirements:
- are pairwise disjoint.
- are pairwise disjoint.
- are pairwise disjoint.
- are pairwise disjoint.
Here, for all , and cannot be the same.
Input Format
The first line contains a positive integer .
The next lines each contain two positive integers , representing the two endpoints of a segment.
Two segments are disjoint if and only if or .
Output Format
The first line contains a positive integer .
The next lines each contain two positive integers , representing a pair of segment indices.
8
1 5
3 10
4 8
9 12
11 16
14 15
20 22
15 21
3
1 3
4 6
8 7
见附件
见附件
见附件
见附件
Hint
If your first line is correct but your construction is not (you may choose not to output a construction; in this case, do not output a newline), you can get of the score.
If your construction is valid and the first line differs from the answer by at most , you can get of the score.
| Subtask ID | Constraints | Score |
|---|---|---|
| 1 | 40 | |
| 2 | 60 |
Translated by ChatGPT 5