#P2161. [SHOI2009] 会场预约
[SHOI2009] 会场预约
Description
There is an empty auditorium in the PP Building that can provide a meeting venue for companies or organizations.
Most of these meetings require several consecutive days (some may require only one day). However, there is only one venue, so the times of different meetings cannot conflict. That is, the end date of the previous meeting must be before the start date of the next meeting. Therefore, to accept a new reservation request, all reservations that conflict with it must be rejected.
In general, if the PP Building has already accepted a venue reservation (for example, from day to day ), then it will not accept any reservation that conflicts with it (for example, from day to day ).
However, sometimes for economic reasons, the PP Building will reject one or even several previously accepted reservations in order to accept a new one. Therefore, the administrator QQ’s notebook often records such information. (For convenience in this problem, all dates are represented by an integer.) For example, if a -day meeting runs from day to day , then the earliest the next meeting can start is day . (There is a contradiction here; if you cannot understand, please refer to the formal description.)
Recently, the workload has been increasing. The administrator QQ hopes you, a participant in SHTSC, can design a computer system to make the work easier. This system should be able to perform the following two operations:
Operation A: A new reservation is from day to day , and all reservations that conflict with it are rejected. When performing this operation, your system should return the number of reservations that were rejected for this new reservation, so QQ can check against the records.
Operation B: Your system should return the current total number of valid reservations.
Input Format
The first line contains a positive integer , the number of operations.
Then follow lines, each describing one operation, which is one of the two types above.
Output Format
Output lines, each with one integer, representing the answer for the corresponding operation.
6
A 10 15
A 17 19
A 12 17
A 90 99
A 11 12
B
0
0
2
0
1
2
Hint
Constraints:
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号