Author: lllyouo
Date: 20251016
tag: 队列
link: https://www.luogu.com.cn/problem/P2058问题描述
分析
略
参考代码
cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, t, k, x, ans, tb[N];
vector<int> vx[N];
queue<pair<int, int>> q;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> t >> k;
while (q.size() && q.front().second <= t - 86400) {
for (int j = 0; j < vx[q.front().first].size(); j++) {
tb[vx[q.front().first][j]]--;
if (!tb[vx[q.front().first][j]]) ans--;
}
q.pop();
}
q.push({i, t});
for (int j = 1; j <= k; j++) {
cin >> x;
vx[i].push_back(x);
if (!tb[x]) ans++;
tb[x]++;
}
cout << ans << endl;
}
return 0;
}