{"problem":{"name":"Reverse and Inversion","description":{"content":"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$. ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc154_e"},"statements":[{"statement_type":"Markdown","content":"For a permutation $Q=(Q_1,Q_2,\\dots,Q_N)$ of $(1,2,\\dots,N)$, let $f(Q)$ be the following value:\n\n> 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$.\n\nYou are given a permutation $P=(P_1,P_2,\\dots,P_N)$ of $(1,2,\\dots,N)$.\nLet us repeat the following operation $M$ times.\n\n*   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.\n\nThere 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.\nFind the sum of these $\\left(\\frac{N(N+1)}{2}\\right)^{M}$ values, modulo $998244353$.\n\n## Constraints\n\n*   $1 \\le N,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":"arc154_e","tags":[],"sample_group":[["2 1\n1 2","1\n\nThere are three ways to perform the operation, as follows.\n\n*   Choose $(i,j)=(1,1)$, making $P=(1,2)$, where $f(P)=0$.\n*   Choose $(i,j)=(1,2)$, making $P=(2,1)$, where $f(P)=1$.\n*   Choose $(i,j)=(2,2)$, making $P=(1,2)$, where $f(P)=0$.\n\nThus, the answer is $0+1+0=1$."],["3 2\n3 2 1","90"],["10 2023\n5 8 1 9 3 10 4 7 2 6","543960046"]],"created_at":"2026-03-03 11:01:13"}}