#C10737. Parking Lot Operations
Parking Lot Operations
Parking Lot Operations
You are given a parking lot represented as an M x N grid. Initially, all cells in the grid are empty (denoted by a dot .
). You need to process a sequence of operations. Each operation is one of the following:
- P x y: Park a car at position (x, y) if the cell is empty. The parked car is represented by a capital letter
C
. - R x y: Remove the car from position (x, y) if there is one.
- Q: Query the current state of the parking lot. For each query, output the entire grid.
When multiple queries occur, the outputs of each query should be separated by an empty line. All coordinates use 0-indexing and it is guaranteed that the provided coordinates are within the bounds of the grid.
The operations must be processed sequentially. Your task is to simulate these operations and output the state of the parking lot whenever a query (Q
) operation is encountered.
The key formula used in this problem is the matrix representation of the parking lot, given by \(\text{grid}\) of size \(M\times N\). Each update is applied to \(\text{grid}[x][y]\) accordingly.
inputFormat
The first line of input contains two integers \(M\) and \(N\) representing the number of rows and columns of the parking lot grid.
The second line contains an integer \(K\) representing the number of operations.
The following \(K\) lines each contain an operation in one of the following formats:
P x y
: Park a car at the position \((x, y)\).R x y
: Remove a car from the position \((x, y)\).Q
: Query the current parking lot state.
outputFormat
For each query operation (Q
), output the current state of the parking lot as \(M\) lines, each containing \(N\) characters. A cell with a parked car is represented by C
and an empty cell by .
.
If there are multiple query operations, separate the output blocks for each query with a blank line.
## sample3 3
5
P 1 1
P 0 0
Q
R 1 1
Q
C..
.C.
...
C..
...
...
</p>