Break, Don't Build
Time limit2sMemory limit1024 MB
Given a 2-regular geometric graph on n points, remove one incident edge per point so that the remaining edges form a non-crossing set, or report NO.
- Level
Hard8 of 10
- Topics
- Graph, Geometry, Divide and conquer
- Solved
- No attempts yet
Problem
Everyone has left the house, so Alf has nothing to do. Then he noticed a map of Los Angeles on the wall and decided to study it. Alf is most interested in the roads, since there were none on his home planet Melmac. Cars there have been flying for ages.
The road system of Los Angeles is a set of points in general position on a plane. Pairs of points are joined by segments, which are two-way roads. Exactly two segments leave each point. Alf found this surprising.
Alf copied the road system onto a sheet of paper and decided to remove some roads, because he loves breaking things. He does not want to remove just any roads. He wants to remove exactly one road from each point so that no two remaining roads intersect. Two roads intersect if they share a common point other than their endpoints.
Alf is very curious. Help him find out whether he can do what he wants.
Input
The first line contains an integer (), the number of points. Each of the next lines contains two integers (), the coordinates of the -th point.
The next lines follow. Line contains two integers (, ), the numbers of the points connected to point by segments.
No two points coincide, and no three points lie on one line. All segments have nonzero length.
Output
If it is impossible to remove exactly one segment from each point under these conditions, print NO. Otherwise, print YES on the first line. Then print lines, where line contains (), the number of the segment to remove at point . The segment leading to point has number 1, and the segment leading to point has number 2.