Cyclic Marathon
Time limit3sMemory limit256 MB
Runners spaced around a circular track catch and eliminate the runner ahead, and the program prints the elimination order and the survivors.
- Level
Medium7 of 10
- Topics
- Heap, Linked list, Simulation, Math
- Solved
- No attempts yet
Problem
A cyclic marathon takes place on a circular track of length . One point on the track is the start and finish line. runners stand on the track at distances measured clockwise from that point and receive start numbers through , starting with the runner closest to the line.
After the start signal, each runner moves clockwise at speed . If a runner catches the runner directly ahead, the caught runner is eliminated.
The race continues until no further eliminations are possible. Every runner still on the track is a winner. Write a program that prints the elimination order.
Input
The first line contains positive integers and (, ).
Each of the next lines describes one runner: starting position and speed . The positions satisfy , and each speed is a real number with two decimal places, . Distances are in meters and speeds are in meters per second.
Output
Print one line per eliminated runner with that runner's start number. Each of these lines ends with a single trailing space.
The last line must be Winner(s): followed by one space and the start numbers of all winners in increasing order, separated by single spaces.