Van Gogh's Work Schedule
Time limit1sMemory limit64 MB
Simulate a first-come queue of painting jobs and print arrivals, starts, and finishes for hours 0 to 23.
- Level
Easy2 of 10
- Topics
- Simulation, Queue
- Solved
- No attempts yet
Problem
Van Gogh paints pictures for customers, and customers are served in the order they arrive. He has no job at the start and begins working at .
When a customer arrives, Van Gogh writes down three values: the customer number , the time until the next customer arrives, and the time needed to paint that picture. The first customer of a test case arrives at , and every later customer arrives at the previous customer's arrival time plus the the previous customer was given. An of means no further customer arrives.
Van Gogh paints one picture at a time. He finishes the current picture before starting the next one, and he paints in arrival order. Each picture therefore starts at the later of the customer's arrival time and the finish time of the previous picture, and it ends hours after it starts.
Print the work schedule for the hours from hour to hour .
Input
The first line has the number of test cases ().
Each test case spans several lines. A line holds three integers , , separated by spaces: the customer number (), the time until the next customer arrives (), and the time needed for that customer's picture (). On the line of the last customer, is . A test case ends with a line where . Every test case has at least one customer.
Output
For each test case print lines, one for every hour from to . A line holds four values joined with no separator: the hour, the number of the customer who arrives at that hour, the number of the customer whose picture Van Gogh starts at that hour, and the number of the customer whose picture is finished at that hour. Print - in a position where no such event happens. Arrivals, starts and finishes that fall at hour or later do not appear in the schedule.
Print one blank line between test cases.