PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FT0000117. Thông báo chưa đọc của Thor (Thor)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Thông báo chưa đọc của Thor (Thor)
Thor
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Thor has phone applications. Every newly created notification gets a global creation number, starting at , regardless of its application. Initially there are no notifications.
Process events in chronological order:
1 x: application creates one new unread notification.2 x: mark all notifications created so far by application as read. Future notifications remain unread until read.3 t: mark the globally first created notifications as read, not the first currently unread notifications. Already-read notifications may be read again.
After every event output the total number of unread notifications. Reading never deletes a notification.
Input
- First line: two integers (applications and events).
- Next lines: an event
1 x,2 x, or3 tin chronological order. - For every type
3, at least notifications have been created so far.
Output
Print exactly lines: the unread notification count after each event.
Subtasks
- Subtask 1 (20 points): , ; for type
1and2, ; for type3, the number of type1events so far. - Subtask 2 (30 points): , ; for type
1and2, ; for type3, the number of type1events so far. - Subtask 3 (50 points): , ; for type
1and2, ; for type3, the number of type1events so far.
Examples
Example 1
Input
3 4
1 3
1 1
1 2
2 3
Output
1
2
3
2
Explanation
- Event 1,
1 3: new notification #1 from app 3; unread = 1. - Event 2,
1 1: new notification #2 from app 1; unread = 2. - Event 3,
1 2: new notification #3 from app 2; unread = 3. - Event 4,
2 3: mark all existing notifications of app 3 as read; unread = 2.
Example 2
Input
4 8
1 2
1 4
2 2
1 2
3 2
1 3
2 4
3 4
Output
1
2
1
2
1
2
2
0
Explanation
- Event 1,
1 2: new notification #1 from app 2; unread = 1. - Event 2,
1 4: new notification #2 from app 4; unread = 2. - Event 3,
2 2: mark all existing notifications of app 2 as read; unread = 1. - Event 4,
1 2: new notification #3 from app 2; unread = 2. - Event 5,
3 2: mark global notifications 1 through 2 as read; unread = 1. - Event 6,
1 3: new notification #4 from app 3; unread = 2. - Event 7,
2 4: mark all existing notifications of app 4 as read; unread = 2. - Event 8,
3 4: mark global notifications 1 through 4 as read; unread = 0.