|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||256 MB||19||4||2||15.385%|
Lisa writes a log analysis application for a distributed computer system. Unlike single-node logs, that are append-only the distributed log is highly volatile. When a node becomes online, it may push a batch of events in the past of the log. Conversely, when it goes oﬄine some log entries may disappear.
To ensure the stability and availability of the application Lisa need to monitor the number of distinct events in the log segments. She is going to handle distributed part, while you have to implement a local one.
Your program is started from the empty log and must support the following operations:
The events are indexed starting from 1. The event types are represented by single-letter codes.
The ﬁrst line of the input ﬁle contains single integer number n — the number of operations (1 ≤ n ≤ 30 000). The following n lines contain one operation description each.
Operation description starts with operation type: ‘+’ for insert, ‘-’ for remove and ‘?’ for query. Operation type is followed by operation arguments.
All indices are valid, i. e. events with speciﬁed indices exist, and you never have to remove events past the end of the log.
The 〈number〉 for the insert and remove operations does not exceed 10 000.
Event types are represented by lowercase Latin letter.
For each query operation output a single number — the number of distinct event types between 〈index1〉 and 〈index2〉 inclusive.
8 + 1 4 w + 3 3 o ? 2 3 - 2 2 ? 2 3 + 2 2 t ? 1 6 - 1 6
2 1 3