AtCoder Regular Contest 176 (Sponsored by Mynavi)
D
Swap Permutation
AtCoder
⌀ 2572
原题
← CE →
翻译中…

Problem Statement

翻译中…

You are given a permutation $P=(P_1,P_2,\dots,P_N)$ of $(1,2,\dots,N)$. You will perform the following operation $M$ times:

翻译中…
  • Choose a pair of integers $(i, j)$ such that $1 \le i < j \le N$, and swap $P_i$ and $P_j$.
翻译中…

There are $\left(\frac{N(N-1)}{2}\right)^M$ possible sequences of operations. For each of them, consider the value $\sum_{i=1}^{N-1} |P_i - P_{i+1}|$ after all the operations. Find the sum, modulo $998244353$, of all those values.

翻译中…

Constraints

翻译中…
  • $2 \le N \le 2 \times 10^5$
  • $1 \le 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 the answer.

翻译中…

样例

Input #1
3 1
1 3 2
Output #1
8
There are three possible sequences of operations: - Choose $(i,j) = (1,2)$, making $P=(3,1,2)$. - Choose $(i,j) = (1,3)$, making $P=(2,3,1)$. - Choose $(i,j) = (2,3)$, making $P=(1,2,3)$. The values of $\sum_{i=1}^{N-1} |P_i - P_{i+1}|$ for these cases are $3$, $3$, $2$, respectively. Thus, the answer is $3 + 3 + 2 = 8$.
Input #2
2 5
2 1
Output #2
1
Input #3
5 2
3 5 1 4 2
Output #3
833
Input #4
20 24
14 1 20 6 11 3 19 2 7 10 9 18 13 12 17 8 15 5 4 16
Output #4
203984325
题目信息
题号
arc176_d
时间限制
4 s
内存限制
1024 MB

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