Garden
Time limit1sMemory limit1024 MB
Given a closed polygon fence and a viewer position, list the fence segments whose visible part has a length greater than zero.
- Level
Medium6 of 10
- Topics
- Geometry, Brute force
- Solved
- No attempts yet
Problem
Onu Uno is building a fence around his farm. The fence is a closed polyline made of straight segments. Each segment starts where the previous one ends, and the last segment ends at the starting point of the first one. The segments are numbered in counterclockwise order. No two fence segments cross or touch, except at the shared endpoints of consecutive segments.
After the fence is finished, Onu Uno wants to look it over. Write a program that takes Onu Uno's position and finds which fence segments he can see from there. He may stand inside or outside the fence, but he cannot stand on the same line as any fence segment.
Onu Uno can see a fence segment if there is a straight line from his position to some point of that segment that does not cross or touch any other fence segment. In other words, the visible part of the segment must have a length greater than zero.
Input
The first line contains the number of fence segments (). The second line contains two space-separated integers and , the coordinates of Onu Uno. Each of the next lines contains two space-separated integers: on line , the coordinates and of the starting point of fence segment . All coordinates are integers with absolute value at most .
Output
On the first line, print one integer , the number of fence segments Onu Uno can see. On the second line, print the visible segment numbers in increasing order, separated by spaces.