Windmill Animation
Time limit1sMemory limit128 MB
Simulate a line rotating counter-clockwise about a pivot point, switching pivot whenever the line hits another of the given points, and report the first S pivots. Repeat for each dataset.
- Level
Medium5 of 10
- Topics
- Geometry, Simulation, Sorting, Math
- Solved
- No attempts yet
Problem
A windmill animation works as follows.
A set of points in the plane is given, no three of which are collinear. One of the points is chosen as the first pivot, and a line is drawn through it at some initial angle. The animation then rotates the line counter-clockwise about the pivot at a constant rate. As soon as the rotating line reaches another of the points, that point becomes the new pivot, and the rotation continues about it. (The line is undirected, so it reaches a point when its angle, taken modulo , equals the direction from the current pivot toward that point.)
Given the set of points, the initial pivot, and the initial angle of the line, write a program that outputs the sequence of pivot points in the order they become the pivot. The rate of rotation does not affect the result; only the order in which points become pivots matters.
Input
The first line of input contains a single integer (), the number of data sets. The data sets are processed identically and independently.
The first line of each data set contains three integers , , and a floating-point value , separated by spaces. () is the number of points, () is the number of pivot points to output, and () is the index of the initial pivot. () is the angle, in degrees, by which the initial line is rotated counter-clockwise from horizontal.
The next lines give the points: the -th of these lines contains the and coordinates (floating-point values) of the point with index . No three points are collinear.
Output
For each data set, output a single line containing space-separated point indices: the points that become pivots, in order, starting with the first pivot after the initial one. (The initial pivot's index is not printed at the front, but it may appear later if it becomes a pivot again.)