#C5885. Cinema Reservation System
Cinema Reservation System
Cinema Reservation System
You are required to implement a cinema reservation system which supports reservation management and seat availability queries. The system starts with seats numbered from 1 to \(10^5\) (i.e., 100000) available. It supports four types of operations:
- RESERVE x: Reserve the seat with number \(x\). If the seat is already reserved, do nothing.
- CANCEL x: Cancel the reservation for seat number \(x\), making it available again.
- NEXT: Output the smallest seat number currently available. Note that if all seats from 1 to \(10^5\) are reserved, then the next available seat is \(10^5+1\).
- AVAILABLE x: Output "YES" if seat \(x\) is available; otherwise, output "NO".
The input is provided as a sequence of queries read from standard input. The first line contains an integer \(q\) representing the number of queries, followed by \(q\) lines each containing one query. For each query that requires an output (namely, NEXT and AVAILABLE queries), your program should produce the corresponding result on a new line.
inputFormat
The first line contains an integer \(q\) (the number of queries). Each of the following \(q\) lines contains one of the following queries:
- RESERVE x
- CANCEL x
- NEXT
- AVAILABLE x
outputFormat
For each query that produces an output (i.e. the NEXT and AVAILABLE queries), print the result on a new line. The order of outputs should match the order of queries that require an output in the input.
## sample6
RESERVE 3
RESERVE 1
AVAILABLE 2
CANCEL 3
NEXT
AVAILABLE 1
YES
2
NO
</p>