CF704A.Thor
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can't count the number of unread notifications generated by those applications (maybe Loki put a curse on it so he can't).
q events are about to happen (in chronological order). They are of three types:
- Application x generates a notification (this new notification is unread).
- Thor reads all notifications generated so far by application x (he may re-read some notifications).
- Thor reads the first t notifications generated by phone applications (notifications generated in first t events of the first type). It's guaranteed that there were at least t events of the first type before this event. Please note that he doesn't read first t unread notifications, he just reads the very first t notifications generated on his phone and he may re-read some of them in this operation.
Please help Thor and tell him the number of unread notifications after each event. You may assume that initially there are no notifications in the phone.
雷神正在逐渐适应地球的生活。作为礼物,洛基送给他一部智能手机。这部手机上有 n 个应用程序。雷神对这部手机十分着迷,但他有一个小问题:他无法统计这些应用程序产生的未读通知数量(也许洛基施了诅咒,使他无法做到这一点)。
接下来将按时间顺序发生 q 个事件,事件共分为三类:
- 应用程序 x 生成一条通知(该新通知为未读状态);
- 雷神阅读应用程序 x 到目前为止生成的所有通知(他可能重复阅读某些通知);
- 雷神阅读手机上生成的前 t 条通知(即按时间顺序,前 t 次类型 1 事件所生成的通知)。题目保证在此事件发生前,类型 1 的事件至少已发生 t 次。请注意:他并非阅读前 t 条未读通知,而是直接阅读手机上生成的最开始的 t 条通知;在此操作中,他可能重复阅读其中某些通知。
请帮助雷神,在每次事件后告诉他当前未读通知的总数。初始时,手机中没有任何通知。
输入格式
The first line of input contains two integers n and q (1 ≤ n, q ≤ 300 000) — the number of applications and the number of events to happen.
The next q lines contain the events. The i-th of these lines starts with an integer type__i — type of the i-th event. If type__i = 1 or type__i = 2 then it is followed by an integer x__i. Otherwise it is followed by an integer t__i (1 ≤ type__i ≤ 3, 1 ≤ x__i ≤ n, 1 ≤ t__i ≤ q).
输入的第一行包含两个整数 n 和 q(1≤n,q≤300000),分别表示应用程序的数量和将要发生的事件数量。
接下来的 q 行描述这些事件。其中第 i 行以一个整数 typei 开头,表示第 i 个事件的类型。若 typei=1 或 typei=2,则其后跟一个整数 xi;否则其后跟一个整数 ti(1≤typei≤3,1≤xi≤n,1≤ti≤q)。
输出格式
Print the number of unread notifications after each event.
在每次事件后输出未读通知的数量。
输入输出样例
输入#1
3 4 1 3 1 1 1 2 2 3
输出#1
1 2 3 2
输入#2
4 6 1 2 1 4 1 2 3 3 1 3 1 3
输出#2
1 2 3 0 1 2
说明/提示
In the first sample:
- Application 3 generates a notification (there is 1 unread notification).
- Application 1 generates a notification (there are 2 unread notifications).
- Application 2 generates a notification (there are 3 unread notifications).
- Thor reads the notification generated by application 3, there are 2 unread notifications left.
In the second sample test:
- Application 2 generates a notification (there is 1 unread notification).
- Application 4 generates a notification (there are 2 unread notifications).
- Application 2 generates a notification (there are 3 unread notifications).
- Thor reads first three notifications and since there are only three of them so far, there will be no unread notification left.
- Application 3 generates a notification (there is 1 unread notification).
- Application 3 generates a notification (there are 2 unread notifications).
在第一个样例中:
- 应用程序 3 生成一条通知(此时有 1 条未读通知)。
- 应用程序 1 生成一条通知(此时有 2 条未读通知)。
- 应用程序 2 生成一条通知(此时有 3 条未读通知)。
- 雷神阅读了由应用程序 3 生成的通知,剩余 2 条未读通知。
在第二个样例测试中:
- 应用程序 2 生成一条通知(此时有 1 条未读通知)。
- 应用程序 4 生成一条通知(此时有 2 条未读通知)。
- 应用程序 2 生成一条通知(此时有 3 条未读通知)。
- 雷神阅读了前三条通知;由于截至目前总共仅有三条通知,因此将不再有未读通知剩余。
- 应用程序 3 生成一条通知(此时有 1 条未读通知)。
- 应用程序 3 生成一条通知(此时有 2 条未读通知)。
输入解题思路,AI测评打分。不知道怎么写?