#K79622. Parking Lot Management

    ID: 35350 Type: Default 1000ms 256MiB

Parking Lot Management

Parking Lot Management

You are given a multi-level parking lot. There are L levels, each level has R rows and each row has S parking spots. Vehicles arrive and need to be parked according to the following rules:

  • A car can park in any available spot.
  • A truck requires an entire row to itself. That is, a truck can only be parked if \forall\; i,\; \text{spot}_{row}[i]\,\text{is free} for that row.
  • A bus requires an entire level to itself. In other words, a bus can only be parked if \forall\; j,\; \forall\; i,\; \text{spot}_{row_j}[i]\,\text{is free} for that level.

The parking lot supports the following operations which all return a boolean value indicating success (True) or failure (False):

  1. addCar(level, row, spot)
  2. addTruck(level, row)
  3. addBus(level)
  4. freeSpot(level, row, spot)
  5. freeRow(level, row)
  6. freeLevel(level)

Your task is to simulate the parking lot based on a sequence of commands read from standard input. Each command should be executed in order and the result for each command printed to standard output on its own line.

inputFormat

The input is provided via standard input and has the following format:

L R S
Q
command_1
command_2
...
command_Q

Here,

  • The first line contains three integers: L (number of levels), R (number of rows per level), and S (number of spots per row).
  • The second line contains an integer Q, the number of commands.
  • Each of the following Q lines contains a command in one of the following forms:
    • addCar level row spot
    • addTruck level row
    • addBus level
    • freeSpot level row spot
    • freeRow level row
    • freeLevel level
  • All indices (level, row, spot) are zero-indexed.

outputFormat

For each command, output a single line containing either True or False (without quotes), indicating whether the operation was successful.

## sample
3 2 3
7
addCar 0 1 2
addCar 0 1 2
addTruck 1 1
freeSpot 0 1 2
addCar 0 1 2
freeRow 1 1
addTruck 1 1
True

False True True True True True

</p>