QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#668040 | #9303. Message Bomb | 4eyebird# | RE | 0ms | 0kb | C++17 | 1.5kb | 2024-10-23 10:51:57 | 2024-10-23 10:52:02 |
answer
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define Buff ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
//#define int long long
int n, m, s;
vector<vint> a;
vector<map<int, int>> b;
vector<map<int, int>> c;
vector<ll> ans;
void solve()
{
cin >> n >> m >> s;
a.resize(n + 1);
b.resize(m + 1);
c.resize(m + 1);
ans.resize(m + 1);
auto tq = [&](int x, int y) -> void
{
int l = 0, r = a[y].size() - 1;
while (l < r)
{
int mid = (l + r) >> 1;
if (a[y][mid] < c[x][y])
l = mid + 1;
else
r = mid;
}
int as = a[y].size() - l - b[x][y];
ans[x] += as;
b[x].erase(y);
c[x].erase(y);
};
int T = 0;
while (s--)
{
T++;
int t, x, y;
cin >> t >> x >> y;
if (t == 1)
{
b[x][y] = 0;
c[x][y] = T;
}
else if (t == 2)
{
tq(x, y);
}
else if (t == 3)
{
b[x][y]++;
a[y].push_back(T);
}
}
for (int i = 1; i <= m; i++)
{
for (auto &[j, k]: c[i])
{
tq(i, j);
}
cout << ans[i] << '\n';
}
}
signed main()
{
Buff;
int _T_ = 1;
// cin >> _T_;
while (_T_--)
solve();
return 0;
}
詳細信息
Test #1:
score: 0
Runtime Error
input:
3 3 10 1 3 2 1 3 1 1 1 2 1 2 1 3 1 2 2 3 1 3 3 2 3 2 1 3 3 2 3 2 1