#abc256f. F - Cumulative Cumulative Cumulative Sum

F - Cumulative Cumulative Cumulative Sum

Score : 500500 points

问题描述

给定 NNQQ 和数组 A=(A1,,AN)A=(A_1,\ldots,A_N)

处理 QQ 个查询,每个查询属于以下两种类型之一:

  • 1 x v:将 AxA_x 更新为 vv
  • 2 x:令 Bi=j=1iAjB_i=\sum_{j=1}^{i}A_jCi=j=1iBjC_i=\sum_{j=1}^{i}B_j,以及 Di=j=1iCjD_i=\sum_{j=1}^{i}C_j。输出 DxD_x998244353998244353 取模的结果。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given NN, QQ, and A=(A1,,AN)A=(A_1,\ldots,A_N).
Process QQ queries, each of which is of one of the following two kinds:

  • 1 x v: update AxA_x to vv.
  • 2 x: let Bi=j=1iAjB_i=\sum_{j=1}^{i}A_j, Ci=j=1iBjC_i=\sum_{j=1}^{i}B_j, and Di=j=1iCjD_i=\sum_{j=1}^{i}C_j. Print DxD_x modulo 998244353998244353.

Constraints

  • 1N2×1051 \leq N \leq 2\times10^5
  • 1Q2×1051 \leq Q \leq 2\times10^5
  • 0Ai1090 \leq A_i \leq 10^9
  • 1xN1 \leq x \leq N
  • 0v1090 \leq v \leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format, where queryi{\rm query}_i denotes the ii-th query to be processed:

NN QQ

A1A_1 A2A_2 \ldots ANA_N

query1{\rm query}_1

query2{\rm query}_2

\vdots

queryQ{\rm query}_Q

Each query is given in one of the following two formats:

11 xx vv

22 xx

Output

Print the answer to the queries, with newlines in between.

Sample Input 1

3 3
1 2 3
2 3
1 2 0
2 3

Sample Output 1

15
9

When the 11-st query is given, A=(1,2,3)A=(1,2,3), so B=(1,3,6)B=(1,3,6), C=(1,4,10)C=(1,4,10), and D=(1,5,15)D=(1,5,15); thus, D3=15D_3=15.

When the 33-rd query is given, A=(1,0,3)A=(1,0,3), so B=(1,1,4)B=(1,1,4), C=(1,2,6)C=(1,2,6), and D=(1,3,9)D=(1,3,9); thus, D3=9D_3=9.

Sample Input 2

2 1
998244353 998244353
2 1

Sample Output 2

0

update @ 2024/3/10 10:54:10