#C4018. Workspace Scheduling System

    ID: 47510 Type: Default 1000ms 256MiB

Workspace Scheduling System

Workspace Scheduling System

You are given a workspace scheduling system with three available rooms (numbered 1, 2, 3) and four operations: book, cancel, check, and show.

The operations are defined as follows:

  • book r s e: Attempt to book room r for time interval \( [s,e] \). A booking is successful if there is no booking that overlaps with the given interval. Otherwise, the booking fails.
  • cancel r s e: Cancel an existing booking in room r for the interval \( [s,e] \). If no such booking exists, the cancellation fails.
  • check r t: Check if room r is available at time \( t \). If the time falls within any booked interval, the room is "Not available"; otherwise, it is "Available".
  • show r: Display all bookings in room r in chronological order. Each booking is printed in the format s-e on its own line. If there are no bookings, output "No bookings".

Note: Two intervals \( [s_1,e_1] \) and \( [s_2,e_2] \) are considered overlapping if \( \max(s_1, s_2) \leq \min(e_1, e_2) \).

inputFormat

The first line contains an integer \( T \) representing the number of operations. Each of the next \( T \) lines contains an operation in one of the following forms:

  • book r s e
  • cancel r s e
  • check r t
  • show r

Input is read from standard input (stdin).

outputFormat

For each operation, output its result on a separate line. Note that for the show operation, if there are multiple bookings, the intervals are printed on separate lines. Output is written to standard output (stdout).

## sample
2
book 1 10 11
check 1 10
Booking successful

Not available

</p>