프로그램 명: coci_poklon
제한시간: 1 초
미르코는 생일날 구간의 집합을 받았다. 이 것으로 놀수 있는게 여러개 있지만 그 중 하나는 이 집합에 포함되는 구간으로
일련의 가장 긴 나열을 찾는 것 인데 현재 사용하는 구간은 전에 사용하는 구간에 포함되는 .........
Mirko got a set of intervals for his birthday. There are many games he can play with them. In one of
them, Mirko must find the longest sequence of distinct intervals such that each interval in the
sequence is in the set and that each interval contains the one that follows in the sequence.
Write a program which finds one such longest sequence.
입력
-
The first line of input contains the integer N (1 ≤ N ≤ 100000), the number of intervals in the set.
-
Each of the following N lines contains two integers A and B describing one interval (1 ≤ A < B ≤ 1000000).
출력
-
Output the length K of the longest sequence on the first line.
-
Each of the following K lines should contain one element of the sequence, an interval in the same
format it was given in the input.
입출력 예
input
3
3 4
2 5
1 6
output
3
1 6
2 5
3 4
input
5
10 30
20 40
30 50
10 60
30 40
output
3
10 60
30 50
30 40
input
6
1 4
1 5
1 6
1 7
2 5
3 5
output
5
1 7
1 6
1 5
2 5
3 5
출처:coci
[질/답]
[제출 현황]
[푼 후(0)]