#C12756. Conference Room Booking System
Conference Room Booking System
Conference Room Booking System
You are required to implement a booking system for a small conference room. The system supports the following operations:
- BOOK day start_time end_time: Book the room for the specified day and time interval if the slot is available.
- CANCEL day start_time end_time: Cancel an existing booking for the specified day and time interval.
- QUERY day: Retrieve the list of all booked time slots for the specified day.
A booking is valid only if the requested time slot does not overlap with any existing booking on that day. Two time slots [a, b) and [c, d) are non-overlapping if and only if $$b \le c \text{ or } d \le a.$$
Input will be provided via standard input (stdin) and output should be written to standard output (stdout). Make sure your solution processes each operation in the order they are received.
inputFormat
The first line of input contains an integer T, representing the number of operations. The next T lines each contain an operation in one of the following formats:
- For booking a slot: BOOK <start_time> <end_time>
- For canceling a booking: CANCEL <start_time> <end_time>
- For querying the schedule: QUERY
Here, is a string in the format YYYY-MM-DD and <start_time> and <end_time> are integers representing the starting and ending hour of the booking.
outputFormat
For each operation that produces an output, print the result on a new line:
- For BOOK and CANCEL operations, print either True or False indicating whether the operation was successful.
- For a QUERY operation, print the list of booked time slots for the given day in the format of a Python-style list of tuples. If there are no bookings on that day, print an empty list [].
All outputs should be written to stdout.## sample
5
BOOK 2023-10-01 9 12
QUERY 2023-10-01
BOOK 2023-10-01 11 13
CANCEL 2023-10-01 9 12
QUERY 2023-10-01
True
[(9, 12)]
False
True
[]
</p>