Score : 500 points
问题描述
给定 N、Q 和数组 A=(A1,…,AN)。
处理 Q 个查询,每个查询属于以下两种类型之一:
1 x v:将 Ax 更新为 v。
2 x:令 Bi=∑j=1iAj,Ci=∑j=1iBj,以及 Di=∑j=1iCj。输出 Dx 对 998244353 取模的结果。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given N, Q, and A=(A1,…,AN).
Process Q queries, each of which is of one of the following two kinds:
1 x v: update Ax to v.
2 x: let Bi=∑j=1iAj, Ci=∑j=1iBj, and Di=∑j=1iCj. Print Dx modulo 998244353.
Constraints
- 1≤N≤2×105
- 1≤Q≤2×105
- 0≤Ai≤109
- 1≤x≤N
- 0≤v≤109
- All values in input are integers.
Input is given from Standard Input in the following format, where queryi denotes the i-th query to be processed:
N Q
A1 A2 … AN
query1
query2
⋮
queryQ
Each query is given in one of the following two formats:
1 x v
2 x
Output
Print the answer to the queries, with newlines in between.
3 3
1 2 3
2 3
1 2 0
2 3
Sample Output 1
15
9
When the 1-st query is given, A=(1,2,3), so B=(1,3,6), C=(1,4,10), and D=(1,5,15); thus, D3=15.
When the 3-rd query is given, A=(1,0,3), so B=(1,1,4), C=(1,2,6), and D=(1,3,9); thus, D3=9.
2 1
998244353 998244353
2 1
Sample Output 2
0
update @ 2024/3/10 10:54:10