Printed Circuit Board
Time limit0.1sMemory limit32 MB
Given a simple polygon and an external origin point, find all polygon vertices that can be connected to the origin by a segment not crossing any polygon edge.
- Level
Hard8 of 10
- Topics
- Geometry, Sorting, Divide and conquer
- Solved
- No attempts yet
Problem
A printed circuit board (PCB) mechanically supports and electrically connects electronic components using conductive pathways etched from copper sheets that are laminated onto a nonconductive substrate.
Your company wants to build a new electronic device on a PCB. The design is partially finished and has the shape of a closed polygon with nodes numbered from to . For every , node and node are joined by a straight wire segment, and node is joined back to node . The wire segments are non-crossing: if two segments share a point, that point is an endpoint of both segments, and every node is the endpoint of exactly two segments. Each node has integer coordinates , and the origin is the lower-left corner of the board, which lies outside the polygon.
Write a program that determines every node that can be joined to the origin by a straight wire segment whose only common point with the polygon is that node itself.
Input
The first line contains one integer (), the number of nodes.
Each of the next lines contains two integers and (): line gives the coordinates of node .
Output
On the first line, print one integer : the number of nodes that can be joined to the origin by a straight wire segment meeting the polygon only at that node.
On the second line, print those node numbers in increasing order, separated by single spaces.
Hint
