#P7334. [JRKSJ R1] 吊打

    ID: 6251 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>线段树2021洛谷原创O2优化欧拉公式块状链表,块状数组,分块

[JRKSJ R1] 吊打

Description

You are given a positive integer sequence a1na_{1\sim n} of length nn. Then there are mm operations of two types:

  • 1 l r means taking the square root of alra_{l\sim r} and rounding down, that is, set $\forall i\in [l,r],a_i\gets\lfloor\sqrt{a_i}\rfloor$;
  • 2 l r means squaring alra_{l\sim r}, that is, set i[l,r],aiai2\forall i\in [l,r],a_i\gets a_i^2.

After all operations are finished, output i=1nai\displaystyle\sum_{i=1}^na_i.

Since the answer may be very large, you only need to output it modulo 998244353998244353.

Input Format

The input has m+2m+2 lines.

The first line contains two positive integers n,mn,m.

The second line contains nn positive integers a1na_{1\sim n}.

The next mm lines each contain 33 positive integers describing one operation.

Output Format

Output one line with one integer, the answer modulo 998244353998244353.

1 1
1
1 1 1
1
4 2
1 2 3 4
1 2 4
2 1 4
7
5 5
10 8 10 11 12
2 1 5
1 1 5
1 1 4
2 4 5
1 1 5
18

Hint

Constraints

Test Point Special Restriction
11 n,m10n,m\le 10
22 Guarantee that for any 1 l r operation, the previous operation is 2 l r
33 Guarantee that there are only 1 operations
44 Guarantee that there are only 2 operations
55 Guarantee that all l=1l=1 and r=nr=n
66 n,m103n,m\le 10^3
7207\sim 20 No special restrictions

For all testdata, it is guaranteed that 1n,m2×1051\le n,m\le2\times10^5 and 1ai1091\le a_i\le 10^9.

Translated by ChatGPT 5