AtCoder Regular Contest 149
E
Sliding Window Sort
AtCoder
⌀ 3188
原题
← DF →
翻译中…

Problem Statement

翻译中…

You are given positive integers $N$, $M$, and $K$. Consider the following operation on a sequence of positive integers $A = (A_0, \ldots, A_{N-1})$.

翻译中…
  • Do the following for $k=0, 1, \ldots, K-1$ in this order.
  • Sort $A_{k\bmod N}, A_{(k+1)\bmod N}, \ldots, A_{(k+M-1)\bmod N}$ in ascending order. That is, replace $A_{(k+j)\bmod N}$ with $x_j$ for each $0\leq j < M$, where $(x_0, \ldots, x_{M-1})$ is the result of sorting $A_{k\bmod N}, A_{(k+1)\bmod N}, \ldots, A_{(k+M-1)\bmod N}$ in ascending order.
翻译中…

You are given a permutation $B = (B_0, \ldots, B_{N-1})$ of the integers from $1$ through $N$. Find the number of sequences $A$ of positive integers that will equal $B$ after performing the operation above, modulo $998244353$.

翻译中…

Constraints

翻译中…
  • $2\leq N\leq 3\times 10^5$
  • $2\leq M\leq N$
  • $1\leq K\leq 10^9$
  • $1\leq B_i\leq N$
  • $B_i\neq B_j$ if $i\neq j$.
翻译中…

Input

翻译中…

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

翻译中…

N M K
B_0 \ldots B_{N-1}

翻译中…

Print

翻译中…

Print the number of sequences $A$ of positive integers that will equal $B$ after performing the operation, modulo $998244353$.

翻译中…

样例

Input #1
6 3 5
6 4 2 3 1 5
Output #1
18
For instance, $A = (4,1,5,6,2,3)$ satisfies the condition. On this $A$, the operation will proceed as follows. - The action for $k=0$ changes $A$ to $(1,4,5,6,2,3)$. - The action for $k=1$ changes $A$ to $(1,4,5,6,2,3)$. - The action for $k=2$ changes $A$ to $(1,4,2,5,6,3)$. - The action for $k=3$ changes $A$ to $(1,4,2,3,5,6)$. - The action for $k=4$ changes $A$ to $(6,4,2,3,1,5)$, which equals $B$.
Input #2
6 3 5
6 5 4 3 2 1
Output #2
0
No sequence $A$ satisfies the condition.
Input #3
20 20 149
13 14 15 16 17 18 19 20 1 2 3 4 5 6 7 8 9 10 11 12
Output #3
401576539
All permutations of the integers from $1$ through $20$ satisfy the condition.
题目信息
题号
arc149_e
时间限制
2 s
内存限制
1024 MB

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