#K15231. Parking System Simulator
Parking System Simulator
Parking System Simulator
You are required to implement a parking system simulator. The parking system consists of multiple levels. Each level has a fixed number of parking spots arranged sequentially. For each level, the first 6 spots are of type motorcycle, the next 2 are compact, and the following 2 are large. The system should support the following operations:
- initialize L S: Initialize the parking system with L levels and S spots per level. The spot types are assigned in a cyclic manner from the sequence: 6 motorcycle, 2 compact, and 2 large spots.
- park vehicle_type license_plate: Attempt to park a vehicle with the specified type and license plate number. A motorcycle can park in any spot; a compact vehicle can park in a spot of type compact or large; and a large vehicle can only park in a spot of type large. The parking should occur in the order of levels (starting from level 0) and, within each level, in the order of increasing spot numbers. If a suitable and available spot is found, print the level and spot number separated by a space. Otherwise, print
No available spot
. - unpark license_plate: Unpark the vehicle with the given license plate. If the vehicle is found, print
Vehicle unparked
and free the spot; otherwise, printVehicle not found
. - status license_plate: Check the status of the vehicle with the given license plate. If found, print the level and spot number separated by a space; otherwise, print
Vehicle not found
.
The problem may include LaTeX formatted formulas if needed. For example, you may refer to the parking spot assignment as follows:
$$\text{Spot Types per Level} = [\underbrace{\text{motorcycle}, \dots, \text{motorcycle}}_{6}, \underbrace{\text{compact}, \text{compact}}_{2}, \underbrace{\text{large}, \text{large}}_{2}]$$Your solution should read input from standard input and write output to standard output.
inputFormat
The first line of the input contains an integer N representing the number of commands. Each of the following N lines contains a command. The commands are one of the following formats:
initialize L S
where L is the number of levels and S is the number of spots per level.park vehicle_type license_plate
where vehicle_type is one ofmotorcycle
,compact
, orlarge
and license_plate is a string.unpark license_plate
status license_plate
Note that commands are processed sequentially. The initialize
command does not produce any output.
outputFormat
For each command that requires an output (park
, unpark
, and status
), print the corresponding result on a new line.
- For a successful
park
command, outputlevel spot_number
(both integers separated by a space). If no suitable spot is available, outputNo available spot
. - For the
unpark
command, output eitherVehicle unparked
orVehicle not found
. - For the
status
command, output eitherlevel spot_number
orVehicle not found
.
5
initialize 3 10
park motorcycle 123
status 123
unpark 123
status 123
0 0
0 0
Vehicle unparked
Vehicle not found
</p>