TopCoder

User's AC Ratio

66.7% (2/3)

Submission's AC Ratio

28.6% (2/7)

Tags

Description

Given a size $N$ interger sequence $a_ 0, a_ 1, \dots, a_ {N - 1}$. Process $Q$ queries as follows:

  • 0 l r b c: For each $i = l, l+1, \dots, {r - 1}$, $a_ i \gets b \times a_ i + c$.
  • 1 l r: Print $\sum_ {i = l}^ {r - 1} a_ i \bmod 998244353$.

Input Format

$N$ $Q$
$a_ 0$ $a_ 1$ ... $a_ {N - 1}$
$\textrm{Query}_ 0$
$\textrm{Query}_ 1$
:
$\textrm{Query}_ {Q - 1}$

Output Format

Sample Input 1

5 7
1 2 3 4 5
1 0 5
0 2 4 100 101
1 0 3
0 1 3 102 103
1 2 5
0 2 5 104 105
1 0 5

Sample Output 1

15
404
41511
4317767

Hints

  • $1 \leq N, Q \leq 5 \times 10^ {5}$
  • $0 \leq a_ i, c < 998244353$
  • $1 \leq b < 998244353$
  • $0 \leq l < r \leq N$

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 5000 2097152 2097152
1 5000 2097152 2097152
2 5000 2097152 2097152
3 5000 2097152 2097152
4 5000 2097152 2097152
5 5000 2097152 2097152
6 5000 2097152 2097152
7 5000 2097152 2097152
8 5000 2097152 2097152
9 5000 2097152 2097152
10 5000 2097152 2097152
11 5000 2097152 2097152
12 5000 2097152 2097152
13 5000 2097152 2097152
14 5000 2097152 2097152
15 5000 2097152 2097152
16 5000 2097152 2097152
17 5000 2097152 2097152
18 5000 2097152 2097152