#C13887. Elevator System Simulation
Elevator System Simulation
Elevator System Simulation
This problem simulates an elevator system in a building. The elevator starts at a given floor and processes a list of floor requests based on an initial direction. It first serves all valid requests in the given direction and then processes the remaining valid requests in the reverse order. A request is considered valid if it falls within the range \( [0, 10] \). If an invalid direction is provided (i.e., not 'up' or 'down'), the program must output an error message.
Your task is to implement this functionality by reading input from standard input (stdin) and printing the result to standard output (stdout).
inputFormat
The input consists of multiple lines:
- The first line contains an integer representing the starting floor of the elevator.
- The second line contains a string which is either 'up' or 'down', representing the initial moving direction of the elevator.
- The third line contains an integer ( n ), the number of floor requests.
- The fourth line contains ( n ) space-separated integers, each denoting a floor request.
outputFormat
Output the sequence of floors visited by the elevator as a space-separated list in one line. If the direction is invalid, output: Invalid direction: must be up or down
.## sample
2
up
3
5 1 3
2 3 5 1