天天看点

翻译练习 Day13

题目:Segments | JXNUOJ

翻译:

Segments

1000ms 262144K

描述:

You are given n segments on the Ox-axis. You can drive a nail in any integer point on the Ox-axis line nail so, that all segments containing this point, are considered nailed down. If the nail passes through endpoint of some segment, this segment is considered to be nailed too. What is the smallest number of nails needed to nail all the segments down?

x轴上有n个线段。您可以在牛轴线钉上的任何整数点上钉一个钉子,这样,包含这个点的所有线段都被认为钉住了。如果钉子穿过某一节段的端点,则认为这一节段也被钉住了。要把所有的线段钉进去,最少要用多少个钉子?

输入:

The first line of the input contains single integer number n (1 ≤ n ≤ 1000) — amount of segments. Following n lines contain descriptions of the segments. Each description is a pair of integer numbers — endpoints coordinates. All the coordinates don't exceed 10000 by absolute value. Segments can degenarate to points.

输入的第一行包含单个整数n(1≤n≤1000)-——段的数量。下面的n行包含片段的描述。每个描述是一对整数-——端点坐标。所有坐标的绝对值都不超过10000。段可以变成为点。

输出:

The first line should contain one integer number — the smallest number of nails needed to nail all the segments down. The second line should contain coordinates of driven nails separated by space in any order. If the answer is not unique, output any.

第一行应该包含一个整数———钉住所有线段所需的最小数目。第二行应该包含用空间以任意顺序分隔的打入钉的坐标。如果答案不唯一,则输出任意一个。

样例输入:

2
0 2
2 5
           

样例输出:

1
2 
           

5
0 3
4 2
4 8
8 10
7 7
           

3
7 10 3