#C13888. Concert Venue Booking System

    ID: 43475 Type: Default 1000ms 256MiB

Concert Venue Booking System

Concert Venue Booking System

You are required to implement a concert venue booking system. The venue is represented as a grid of seats with 5 rows and 10 columns. Each seat is initially available and is denoted by O. A booked seat is denoted by X.

The system must support the following operations:

  • book r c: Book the seat at row r and column c. If the seat is available, mark it as booked and output true; otherwise, output false. Out-of-bound coordinates should also return false.
  • cancel r c: Cancel the booking at row r and column c. If the seat was previously booked, cancel it (mark it as available) and output true; otherwise, output false. Out-of-bound coordinates should return false.
  • check r c: Check if the seat at row r and column c is available. Output true if available and false if booked or if the coordinates are out-of-bound.
  • display: Display the current seating chart. Each row should be printed on a new line with seats separated by a single space.

You will process a number of commands given from standard input and output the corresponding responses to standard output. Make sure your solution handles out-of-bound indices correctly.

The methods in your solution may be thought of as analogous to the following functions:

\( book(r, c) \): attempts to book seat at row \( r \) and column \( c \).
\( cancel(r, c) \): cancels the booking of seat at row \( r \) and column \( c \).
\( check(r, c) \): returns whether seat at row \( r \) and column \( c \) is available.
\( display() \): prints the entire seating chart.

Implement the system so that it processes input commands as specified and prints out the result of each command execution.

inputFormat

The first line of input contains a single integer \(T\) representing the number of commands. The following \(T\) lines each contain one command. Each command is one of the following forms:

  • book r c
  • cancel r c
  • check r c
  • display

Here, r and c are zero-indexed integers representing the row and column numbers respectively.

outputFormat

For each command, output the following:

  • For book, cancel, and check commands, output a single line containing either true or false (all lowercase) based on the result.
  • For the display command, output the seating chart as 5 lines, each line containing 10 characters separated by a single space indicating the status of each seat.
## sample
6
book 0 0
book 0 0
check 0 0
cancel 0 0
check 0 0
display
true

false false true true O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O

</p>