#C14543. Parking Lot Management System
Parking Lot Management System
Parking Lot Management System
This problem requires you to implement a parking lot management system to simulate adding parking spots, recording vehicle entries and exits, calculating parking fees, checking available spots, and tracking the occupancy rate over a time interval. The system supports commands for updating the current time, advancing time, and performing operations. The fee is computed as the duration (in hours) multiplied by the rate (compact: $5, large: $10, electric: $15). For the occupancy rate, if a vehicle occupied any time within the given time interval, it is counted as occupying a spot. You are required to implement an interactive system that reads commands from standard input and writes the corresponding outputs to standard output.
Commands:
settime YYYY-MM-DD HH:MM:SS
: Sets the system's current time.advance <seconds>
: Advances the current time by the given number of seconds.add <number> <spot_type>
: Adds a parking spot identified bynumber
with typespot_type
(compact, large, or electric).entry <license_plate> <vehicle_type>
: Records a vehicle's entry. If an available spot of the required type is found, outputtrue
, otherwisefalse
.exit <license_plate>
: Records a vehicle's exit and calculates the fee based on the elapsed time. The fee should be printed rounded to 2 decimal places.available <spot_type>
: Lists the numbers of available parking spots of the given type in ascending order, separated by a space. If none is available, outputnone
.occupancy <start_time> <end_time>
: Computes and prints the occupancy rate (as a percentage with 6 decimal places) over the given time interval. The time format isYYYY-MM-DD HH:MM:SS
.
Note: The current time is maintained internally and updated using the settime
and advance
commands. All commands that produce an output must print the result in a new line.
inputFormat
The first line of input is an integer Q representing the number of commands. The following Q lines each contain one command as described above. Commands and their parameters are space-separated.
outputFormat
For each command that requires an output (entry
, exit
, available
, and occupancy
), print the result on a new line. For boolean outputs, print either 'true' or 'false'. For fees, print a number rounded to 2 decimal places. For occupancy rate, print a number with 6 decimal places.## sample
8
settime 2023-10-10 10:00:00
add 1 compact
add 2 large
entry XYZ123 compact
advance 3600
exit XYZ123
available compact
occupancy 2023-10-10 09:00:00 2023-10-10 11:00:00
true
5.00
1
50.000000
</p>