Exactly One Point
면접 대비시간 제한2초메모리 제한512 MB
n개의 선분이 주어질 때, 각 선분이 정확히 한 점을 포함하고 모든 점이 어떤 선분에 속하도록 서로 다른 점을 배치하거나 불가능함을 판별한다.
문제
There are segments on a line. You should place some points onto this line so that:
- every point is contained in at least one segment,
- every segment contains exactly one point.
입력
The first line contains an integer () --- the number of segments.
Each of the next lines contains two integers and () --- the endpoints of the -th segment.
For convenience, all endpoints of all segments are even numbers from to .
출력
If it's impossible to place points in a required way, output "-1".
Otherwise, in the first line output an integer --- the number of points that should be placed onto the line.
In the next line, output distinct integers from to --- the coordinates of the points.
You don't have to minimize the number of points. If there are several possible solutions, output any of them.