#C7131. Hotel Booking System
Hotel Booking System
Hotel Booking System
You are given a hotel with M rooms, numbered from 0 to M-1. Initially, all rooms are available. The hotel booking manager processes a series of commands to book a range of rooms or check the availability of a single room.
The input begins with two integers, M and a dummy parameter R (which can be ignored), followed by an integer N denoting the number of commands. Each of the next N lines contains a command in one of the following formats:
BOOK x y
— book all rooms from x to y (inclusive).CHECK z
— check if room z is booked. If it is, output \(\text{booked}\); otherwise, output \(\text{available}\).
For each CHECK
command, print the result on a separate line.
Note: Room indexing is 0-based. The dummy parameter R provided in the first line does not affect the simulation.
The mathematical notation for the check result can be represented as follows in \(\LaTeX\):
[ \text{result} = \begin{cases} \text{booked} & \text{if the room is already booked} \ \text{available} & \text{otherwise} \end{cases} ]
inputFormat
The input is read from stdin and has the following structure:
- The first line contains two integers M and R (where R is a dummy parameter).
- The second line contains an integer N representing the number of commands.
- Each of the following N lines contains one command in one of these formats:
BOOK x y
CHECK z
All numbers are integers, and room indices are zero-indexed.
outputFormat
For each CHECK
command, output the result on a new line to stdout. The output should be:
- booked if the checked room has been booked by any previous
BOOK
command. - available if the room is still free.
For example, the output for a series of CHECK
commands might be:
booked available booked## sample
10 5
5
BOOK 2 5
CHECK 4
CHECK 6
BOOK 0 1
CHECK 1
booked
available
booked
</p>