|
||||||||||
Elevator SimulationTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 395 Accepted Submission(s): 8 Problem Description You are to simulate the movements of an elevator, which works according to the following rules: The elevator stays 3 seconds for customers to get in or get out. If some customers want to get in and some want to get out, the elevator stays 6 seconds. It takes the elevator 2 seconds to go one story upwards or downwards. When there is no request for service, the elevator stays where it is. Namely, it is idle. When the elevator is idle, and a request comes from upwards or downwards, it moves upwards or downwards. If a request comes from the story where it stays, the elevator opens its door to serve these customers. When the elevator goes upwards or downwards, it keeps its direction until there is no request from upwards or downwards. However, it breaks off to let customers get out or pick up customers if necessary. If the elevator is to go upwards or downwards, it does not accept customers intending to go upwards or downwards. When the elevator can act more than one way according to aforementioned rules, it chooses the action with the highest priority. The priorities for actions, from the highest to the lowest, are: let customers get out let customers get in go downstairs go upstairs Initially (at time 0), the elevator is in the 0th story, and it is idle. Given the requests, you are to output how the elevator moves in a designated interval. Suppose that each request comes at an integer second. Input The input begins in its first line with the number of stories of a building, and other two numbers representing an interval. These three numbers are separated by a blank. Each of the following lines in the input consists of three numbers, N1, N2, and N3, representing a request coming from N2th story to N3th story at time N1. A line of three 0's separates two test cases. After the last test case, there is a line containing three 0's. Output You have to output what the elevator acts at each second in the designated interval. Behind each case should be one blank line Sample Input
Sample Output
Source | ||||||||||
|