Untitled
unknown
c_cpp
8 months ago
1.6 kB
6
Indexable
#include <bits/stdc++.h>
using namespace std;
void MO3TAZOLEQ() {
#ifdef MOATAZOLEQ
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
#define ll long long
void solve() {
int cnt = 1;
int n, q;
cin >> n >> q;
vector<set<int> > applications(n + 1);
set<pair<int, int> > notifications;
while (q--) {
int tp;
cin >> tp;
if (tp == 1) {
int x;
cin >> x;
applications[x].insert(cnt);
notifications.insert({cnt, x});
cnt++;
} else if (tp == 2) {
int x;
cin >> x;
for (auto notification_number: applications[x]) {
notifications.erase({notification_number, x});
}
applications[x].clear();
} else {
int t;
cin >> t;
vector<pair<int, int> > to_delete;
for (auto notification: notifications) {
if (notification.first > t) {
break;
}
to_delete.push_back(notification);
applications[notification.second].erase(notification.first);
}
for (auto notification: to_delete) {
notifications.erase(notification);
}
}
cout << notifications.size() << '\n';
}
}
int main() {
MO3TAZOLEQ();
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
Editor is loading...
Leave a Comment