#C12863. Elevator Simulation

    ID: 42337 Type: Default 1000ms 256MiB

Elevator Simulation

Elevator Simulation

You are given an elevator simulation problem in a 10-floor building (floors are numbered 0 to 9). The elevator starts on the ground floor (floor 0). It supports the following commands:

  • UP: Move the elevator up by one floor. The elevator cannot go above floor 9.
  • DOWN: Move the elevator down by one floor. The elevator cannot go below floor 0.
  • GOTO X: Move the elevator directly to floor X, if X is between 0 and 9 (inclusive). If X is not valid, ignore the command.
  • PRINT: Output the current floor of the elevator.

You will be given a series of commands on standard input. Process the commands sequentially and for every PRINT command, output the current floor (using LaTeX for mathematical expression: $0 \leq floor \leq 9$).

inputFormat

The first line contains a single integer n which denotes the number of commands. The next n lines each contain a command. Each command is one of the following:

  • UP
  • DOWN
  • GOTO X where X is an integer
  • PRINT

Input is provided via standard input (stdin).

outputFormat

Whenever a PRINT command is encountered, output the current floor of the elevator on a new line. Output is to be written to standard output (stdout).

## sample
5
UP
UP
PRINT
DOWN
PRINT
2

1

</p>