#K3016. Conference Room Manager

    ID: 24865 Type: Default 1000ms 256MiB

Conference Room Manager

Conference Room Manager

You are required to implement a conference room manager system. The system manages booking, cancellation, and query operations for conference rooms. Each booking is defined by a room identifier and a start and end time in the format YYYY-MM-DD HH:MM. A booking is successful if it does not overlap with an existing booking in the same room. Otherwise, it fails.

For two bookings with time intervals \( [start_1, end_1] \) and \( [start_2, end_2] \), they do not conflict if and only if \[ end_1 \leq start_2 \quad \text{or} \quad start_1 \geq end_2 \]

The system should also support cancellation of a booking given the room and the exact start time, and querying the available time slots for a given room and day. When querying, the entire day (from 00:00 to 23:59) is considered, and the available slots are reported in the form HH:MM-HH:MM separated by a space.

The operations are issued in an input sequence and should be processed in order.

inputFormat

The first line contains an integer \(N\) representing the number of operations. The following \(N\) lines each contain an operation command in one of the three formats:

  • Booking: Book room YYYY-MM-DD HH:MM YYYY-MM-DD HH:MM — Attempt to book the room between the given start and end times.
  • Cancellation: Cancel room YYYY-MM-DD HH:MM — Cancel the booking that starts at the given time in the specified room.
  • Query: Query room YYYY-MM-DD — Query available time slots for the specified room on the given day.

All times are given in the specified formats. The input is read from standard input (stdin).

outputFormat

For each operation in the input, output the result on a separate line. For booking and cancellation operations, output either Booking successful, Booking failed, Cancellation successful, or Cancellation failed accordingly. For query operations, output a single line containing all available time intervals (in the format HH:MM-HH:MM) separated by a single space. The output should be written to standard output (stdout).

## sample
2
Book A 2023-10-01 09:00 2023-10-01 11:00
Query A 2023-10-01
Booking successful

00:00-09:00 11:00-23:59

</p>