#P6390. [COCI 2007/2008 #4] POKLON
[COCI 2007/2008 #4] POKLON
Problem Description
Given intervals, Mirko wants to construct some intervals such that each later interval is a sub-interval of the previous one, and every number in these intervals is contained in the given intervals.
Input Format
The first line contains an integer .
The next lines each contain two integers , representing a given interval.
Output Format
The first line contains an integer , which is the number of intervals that can be constructed.
The next lines each contain two integers, in order, representing the constructed intervals.
3
3 4
2 5
1 6
3
1 6
2 5
3 4
5
10 30
20 40
30 50
10 60
30 40
3
10 60
30 50
30 40
6
1 4
1 5
1 6
1 7
2 5
3 5
5
1 7
1 6
1 5
2 5
3 5
Hint
Constraints
For of the testdata, it is guaranteed that and .
Notes
This problem is translated from COCI2007-2008 CONTEST #4 T5 POKLON。
Translated by ChatGPT 5