Logo
(追記) (追記ここまで)

7781번 - Log Analysis 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB214215.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 offline 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:

  • insert ⟨index⟩ ⟨number⟩ ⟨type⟩ — inserts ⟨number⟩ of events of type ⟨type⟩ before event with index ⟨index⟩. Events with indices larger or equal to ⟨index⟩ are renumbered.
  • remove ⟨index⟩ ⟨number⟩ — removes ⟨number⟩ of events starting from event with index ⟨index⟩.
  • query ⟨index1⟩ ⟨index2⟩ — counts the number of distinct event types for events with indices from ⟨index1⟩ to ⟨index2⟩ inclusive.

The events are indexed starting from 1. The event types are represented by single-letter codes.

입력

The first line of the input file 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 specified 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.

제한

예제 입력 1

8
+ 1 4 w
+ 3 3 o
? 2 3
- 2 2
? 2 3
+ 2 2 t
? 1 6
- 1 6

예제 출력 1

2
1
3

힌트

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > NEERC Northern Subregional 2012 L번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /