#C3998. Event Seating Management
Event Seating Management
Event Seating Management
In this problem, you are asked to manage seating for an event. There are ( n ) seats, numbered from 1 to ( n ), initially all empty. You will be given ( m ) commands. Each command is one of the following types:
- A x: Add an attendee to seat \( x \), if the seat is not already occupied.
- R x: Remove the attendee from seat \( x \), if the seat is currently occupied.
- C l r: Count and output the number of occupied seats in the range from \( l \) to \( r \) (inclusive).
The input is read from standard input (stdin) and the output must be written to standard output (stdout). Ensure your program can process commands sequentially and output the results for the count queries accordingly.
inputFormat
The first line contains two integers ( n ) and ( m ), where ( n ) is the number of seats and ( m ) is the number of commands. The following ( m ) lines each contain one command in one of the following formats:
- A x
- R x
- C l r
For count commands (starting with C), you should output a line with the number of occupied seats in the specified range.
outputFormat
For each count command (that starts with 'C'), output a single integer on a new line representing the number of occupied seats in the range ( [l, r] ). There is no output for add (A) or remove (R) commands.## sample
10 5
A 3
A 5
C 1 10
R 3
C 1 10
2
1
</p>