AtCoder Beginner Contest 405(Promotion of AtCoder Career Design DAY)
G
Range Shuffle Query
AtCoder
⌀ 2354
原题
翻译中…

Problem Statement

翻译中…

You are given a length-$N$ sequence $A = (A_1, A_2, \dots, A_N)$. Process $Q$ queries. Each query gives you integers $L$, $R$, $X$ and asks you to solve the following.

翻译中…

Let $B = (A_L, A_{L+1}, \dots, A_R)$ be the sequence formed by the $L$-th through $R$-th elements of $A$. Perform the following procedure exactly once:

  • First, remove from $B$ every element whose value is at least $X$.
  • Then, rearrange the remaining elements of $B$ arbitrarily.

How many distinct sequences $B$ can result? Find the count modulo $998244353$.

翻译中…

Constraints

翻译中…
  • $1 \le N \le 2.5 \times 10^5$
  • $1 \le Q \le 2.5 \times 10^5$
  • $1 \le A_i \le N$
  • $1 \le L \le R \le N$
  • $1 \le X \le N$
  • All input values are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format, where $\mathrm{query}_i$ denotes the $i$‑th query:

翻译中…

N Q
A_1 A_2 \dots A_N
\mathrm{query}_1
\mathrm{query}_2
\vdots
\mathrm{query}_Q

翻译中…

Each query is given in the following format:

翻译中…

L R X

翻译中…

Output

翻译中…

Output $Q$ lines. The $i$-th line should contain the answer to the $i$‑th query.

翻译中…

样例

Input #1
5 3
1 2 3 3 1
1 5 3
3 4 1
1 3 4
Output #1
3
1
6
For the first query, there are three possible resulting sequences $B$: $(1,1,2)$, $(1,2,1)$, and $(2,1,1)$. For the second query, there is one possible resulting sequence $B$: the empty sequence $()$.
Input #2
8 6
6 2 4 1 5 1 8 6
5 6 3
1 5 7
1 4 6
4 7 8
4 8 2
5 8 6
Output #2
1
120
6
3
1
2
题目信息
题号
abc405_g
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。