{"problem":{"name":"Swap Permutation","description":{"content":"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 s","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":4000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc176_d"},"statements":[{"statement_type":"Markdown","content":"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:\n\n*   Choose a pair of integers $(i, j)$ such that $1 \\le i < j \\le N$, and swap $P_i$ and $P_j$.\n\nThere 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.\n\n## Constraints\n\n*   $2 \\le N \\le 2 \\times 10^5$\n*   $1 \\le M \\le 2 \\times 10^5$\n*   $(P_1,P_2,\\dots,P_N)$ is a permutation of $(1,2,\\dots,N)$.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $M$\n$P_1$ $P_2$ $\\dots$ $P_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc176_d","tags":[],"sample_group":[["3 1\n1 3 2","8\n\nThere are three possible sequences of operations:\n\n*   Choose $(i,j) = (1,2)$, making $P=(3,1,2)$.\n*   Choose $(i,j) = (1,3)$, making $P=(2,3,1)$.\n*   Choose $(i,j) = (2,3)$, making $P=(1,2,3)$.\n\nThe 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$."],["2 5\n2 1","1"],["5 2\n3 5 1 4 2","833"],["20 24\n14 1 20 6 11 3 19 2 7 10 9 18 13 12 17 8 15 5 4 16","203984325"]],"created_at":"2026-03-03 11:01:13"}}