#K84192. Parking Lot Management
Parking Lot Management
Parking Lot Management
This problem involves designing a parking lot management system with a fixed capacity of \(10\) parking spaces. You are required to implement a ParkingLot
data structure that supports the following operations:
- park reg_number: Parks a vehicle with the given registration number in the first available parking space. If the parking lot is full, output
Parking lot is full
. - leave space_number: Vacates the parking space with the given space number. If the space is already empty, output
Space is already empty
. - status: Outputs the current status of the parking lot as a dictionary whose keys are the parking space numbers (from 1 to 10) and values are the registration numbers (or
None
if the space is empty).
The operations will be provided as commands via stdin and your solution should write the appropriate output to stdout as described.
inputFormat
The first line of input is an integer \(Q\) representing the number of commands. The following \(Q\) lines each contain one of the three commands:
park reg_number
leave space_number
status
For example:
5 park KA-01-HH-1234 park KA-01-HH-9999 status leave 2 status
outputFormat
For each command that requires an output, print the result to stdout:
- For the
park
command, if the parking lot is full, printParking lot is full
. Otherwise, do not print anything. - For the
leave
command, if the specified parking space is already empty, printSpace is already empty
. Otherwise, do not print anything. - For the
status
command, print the current status of the parking lot as a dictionary. For example:
{1: 'KA-01-HH-1234', 2: 'KA-01-HH-9999', 3: None, 4: None, 5: None, 6: None, 7: None, 8: None, 9: None, 10: None}
5
park KA-01-HH-1234
park KA-01-HH-9999
status
leave 2
status
{1: 'KA-01-HH-1234', 2: 'KA-01-HH-9999', 3: None, 4: None, 5: None, 6: None, 7: None, 8: None, 9: None, 10: None}
{1: 'KA-01-HH-1234', 2: None, 3: None, 4: None, 5: None, 6: None, 7: None, 8: None, 9: None, 10: None}
</p>