Request for Permission
Time limit1sMemory limit128 MB
Given a convex country, M nearest-station Voronoi cells, and a straight flight segment outside the border, list the cells the flight crosses in order.
- Level
Hard8 of 10
- Topics
- Geometry, Brute force, Implementation, Simulation
- Solved
- No attempts yet
Problem
A world superpower is preparing an air strike on the far side of the globe, and to carry it out it must send several airplanes across another continent. A small country named TidyLand lies along that route and has received a request for permission to fly through its airspace.
The border of TidyLand is a convex polygon. TidyLand's airspace is divided into segments, and each segment is monitored and controlled by exactly one air-control station. The segments are formed so that every point of the airspace is controlled by the station that is nearest to that point.
The request specifies the starting and ending coordinates of the flight (both lie outside TidyLand). The airplane flies in a straight line at a constant altitude; since all control stations share the same altitude, the whole problem is treated in the plane. TidyLand's Air Space Central wants to know which segments the airplane passes through, in the order it enters them.
Input
The first part of the input describes the border of TidyLand. The first line contains a single integer , the number of sides of the border polygon (). Each of the next lines contains the integer coordinates of a vertex (, ). The vertices are listed in clockwise order.
The second part describes the air-control stations. First, a single line contains the integer , the number of stations (). Then the -th of the next lines contains the integer coordinates of the -th station. All stations share the same altitude.
The last part describes the flight path. One line contains four integers (each between and ), where is the start and is the end. Both points lie outside TidyLand.
Output
Print two lines. The first line contains the number of segments the airplane passes through. The second line lists the numbers of those segments, separated by single spaces, in the order the airplane enters them. The stations (segments) are numbered from to in the order they are given in the input.
If the airplane does not enter TidyLand's airspace at all, print a single line containing .