Elevator system
Candidates need to simulate the implementation of a simple elevator control system, the upper and lower floors of each floor request processing, give the elevator simulation running trajectory (in turn, output elevator each time the floor number of the door).
Rules
1. There are only 1 elevators operating in the system.
2. Floors up to 8 floor, elevators in [1,8] floor between the operation, elevator where the initial floor number is set by the input.
3. Elevator passengers do not consider the number of restrictions.
4. The passenger's request for the elevator is integrated in a request command (see later explanations), unlike the actual life elevator.
5. If the elevator status is upstream and the elevator current floor exists on the upstream request or the floor of the elevator above the current floor exists the request, then the elevator remains in the running state for the upstream before these requests are fully processed.
If the elevator status is down and the elevator current floor has a downstream request or the floor of the elevator below the current floor is requested, then the elevator remains in the running state until all of these requests are processed.
For example: Elevator from 5 floor to 6 floor, if the 6 floor has requested a (from 6 floor to 8 floor) and B (requirements from 6 floor to 2 floor), both of the command input time is less than or equal to the elevator reached the 6 floor of the time, then only processing request a, will not process request B, request B needs to wait until the elevator
6. The elevator stops and the guest does not consume the time, only has the elevator movement to consume the time. Lift movement (up or down) a floor consumes 1 units of time. The system initial time is 1.
8. The passenger enters and exits the elevator strictly according to the input order, does not have to the destination floor halfway out the elevator situation does not need to consider.
Command Format description
(1) The request format is:
Srcfloor-destfloor-reqtime
Explain:
Srcfloor: The positive integer of the value range [1,8] for the passenger's source floor number
Destfloor: The target floor number that the passenger wishes to reach, the positive integer value range [1,8]
Reqtime: The time at which the passenger initiates the request, with a positive integer value.
Srcfloor, Destfloor, Reqtime separated by "-"
(2) The format of the request list is:
Request1,request2,request3,..., REQUESTN
Each request is separated by a comma.
The following items are guaranteed by the input (candidates do not need to be checked):
(1) The legitimacy of the command format and the legitimacy of the input value;
(2) In the request list, the subsequent request time is greater than the time of the previous request;
(3) the start and destination floors of the request are different.
Run time limit: |
Unlimited |
Memory Limit: |
Unlimited |
Input: |
Elevator Initial floor Number Request List |
Output: |
The operating track of the elevator (i.e., the floor number where the elevator is opened each time it opens, each floor number is separated by "-") |
Sample input: |
13-5-1,8-1-2,5-2-3 |
Sample output: |
3-5-8-5-2-1 |
Huawei Hangxia Regional Intern Experience Machine test (elevator problem)