AtCoder Regular Contest 154
E
Reverse and Inversion
AtCoder
⌀ 3506
原题
← DF →
翻译中…

Problem Statement

翻译中…

For a permutation $Q=(Q_1,Q_2,\dots,Q_N)$ of $(1,2,\dots,N)$, let $f(Q)$ be the following value:

翻译中…

the sum of

j-i

over all pairs of integers

(i,j)

such that

1 \le i < j \le N

and

Q_i > Q_j

.

翻译中…

You are given a permutation $P=(P_1,P_2,\dots,P_N)$ of $(1,2,\dots,N)$.

翻译中…

Let us repeat the following operation $M$ times.

翻译中…
  • Choose a pair of integers $(i,j)$ such that $1 \le i \le j \le N$. Reverse $P_i,P_{i+1},\dots,P_j$. Formally, replace the values of $P_i,P_{i+1},\dots,P_j$ with $P_j,P_{j-1},\dots,P_i$ simultaneously.
翻译中…

There are $\left(\frac{N(N+1)}{2}\right)^{M}$ ways to repeat the operation. Assume that we have computed $f(P)$ for all those ways.

翻译中…

Find the sum of these $\left(\frac{N(N+1)}{2}\right)^{M}$ values, modulo $998244353$.

翻译中…

Constraints

翻译中…
  • $1 \le N,M \le 2 \times 10^5$
  • $(P_1,P_2,\dots,P_N)$ is a permutation of $(1,2,\dots,N)$.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N M
P_1 P_2 \dots P_N

翻译中…

Output

翻译中…

Print a single line containing the answer.

翻译中…

样例

Input #1
2 1
1 2
Output #1
1
There are three ways to perform the operation, as follows. - Choose $(i,j)=(1,1)$, making $P=(1,2)$, where $f(P)=0$. - Choose $(i,j)=(1,2)$, making $P=(2,1)$, where $f(P)=1$. - Choose $(i,j)=(2,2)$, making $P=(1,2)$, where $f(P)=0$. Thus, the answer is $0+1+0=1$.
Input #2
3 2
3 2 1
Output #2
90
Input #3
10 2023
5 8 1 9 3 10 4 7 2 6
Output #3
543960046
题目信息
题号
arc154_e
时间限制
2 s
内存限制
1024 MB

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