test/yosupo/data_structure/queue_operate_all_composite.test.cpp
✅
AC
· 最終更新 2026-09-07
· GitHub
問題: https://judge.yosupo.jp/problem/queue_operate_all_composite
依存するヘッダ(5)
実装
// competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/queue_operate_all_composite
#include <iostream>
#include "data_structure/swag.hpp"
#include "number_theory/modint.hpp"
using Mint = modint998;
int main(void) {
int q;
std::cin >> q;
sliding_window_aggregation<Rev<Affine<Mint>>> swag;
while (q--) {
int c;
std::cin >> c;
if (c == 0) {
int a, b;
std::cin >> a >> b;
swag.emplace({a, b});
} else if (c == 1) {
swag.pop();
} else {
int x;
std::cin >> x;
auto p = swag.fold();
std::cout << (p.first * x + p.second) << '\n';
}
}
return 0;
}