No.2345 max(l,r)
レベル :
/ AI推定難易度 : 2225
/ 実行時間制限 : 1ケース 2.000秒 / メモリ制限
: 512 MB / 標準ジャッジ問題
タグ : / 解いたユーザー数 31
作問者 :
ytqm3
/ テスター :
ぷら
shiomusubi496
タグ : / 解いたユーザー数 31
作問者 :
ぷら
shiomusubi496
問題文最終更新日: 2023-06-09 13:44:18
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 392
(順位表)
の他の問題:
Problem Statement
Solve the following problem for $T$ cases.
Find the number, modulo $998244353$, of ways to place $N$ people on a number line such that the following conditions are satisfied.
- The coordinate of every person is an integer between $1$ and $M$, inclusive.
- For every $i\ (1 \le i \le N)$, let $l$ be the number of people at coordinates smaller than that of person $i$, and let $r$ be the number of people at coordinates larger than that of person $i$; then $\max(l,r)=A_i$.
Here, $2$ placements are considered different if and only if there exists a person $i$ such that the coordinate of person $i$ differs between them.
Input
$T$
$\text{case}_1$
$\text{case}_2$
$\vdots$
$\text{case}_T$
Each case is given in the following format.
$N$ $M$ $A_1$ $A_2$ $\ldots$ $A_N$
- $1 \le T \le 2 \times 10^5$
- $1 \le N,M \le 2 \times 10^5$
- $0 \le A_i \le N-1$
- The sum of $N$ over all cases does not exceed $2\times 10^5$.
- All input values are integers.
Output
Print $T$ lines. On the $i$-th line, print the answer for $\text{case}_i$.
Sample
Sample 1
Input
3 5 5 4 3 2 3 4 1 5 0 7 7 1 1 1 1 6 1 1
Output
4 5 42
For the $1$st case: the following $4$ placements are possible.
- Place person $1$ at coordinate $1$, person $2$ at coordinate $2$, person $3$ at coordinate $3$, person $4$ at coordinate $4$, and person $5$ at coordinate $5$.
- Place person $1$ at coordinate $1$, person $2$ at coordinate $4$, person $3$ at coordinate $3$, person $4$ at coordinate $2$, and person $5$ at coordinate $5$.
- Place person $1$ at coordinate $5$, person $2$ at coordinate $2$, person $3$ at coordinate $3$, person $4$ at coordinate $4$, and person $5$ at coordinate $1$.
- Place person $1$ at coordinate $5$, person $2$ at coordinate $4$, person $3$ at coordinate $3$, person $4$ at coordinate $2$, and person $5$ at coordinate $1$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。