CF1677D Tokitsukaze and Permutations
题目描述
有一个长度为 $n$ 的排列 $p$,将执行 $k$ 次操作。
操作过程:对于 $1\sim n$ 中,当 $p_i>p_{i+1}$,则交换 $p_{i},p_{i+1}$。
经过 $k$ 次操作之后,得到了一个新数组 $a$,再定义数组 $v$ 表示在 $1\sim i-1$ 中比 $a_i$ 大的个数。
现在给定 $v$,但是有可能其中的值为 $-1$,这表示它的值并不确定。求有多少种 $p$ 满足在 $k$ 次操作后得到的 $v$ 和给定确定值一致,结果对 $998244353$ 取模。
输入格式
无
输出格式
无
说明/提示
In the first test case, only permutation $ p=[5,4,3,2,1] $ satisfies the constraint condition.
In the second test case, there are $ 6 $ permutations satisfying the constraint condition, which are:
- $ [3,4,5,2,1] $ $ \rightarrow $ $ [3,4,2,1,5] $ $ \rightarrow $ $ [3,2,1,4,5] $
- $ [3,5,4,2,1] $ $ \rightarrow $ $ [3,4,2,1,5] $ $ \rightarrow $ $ [3,2,1,4,5] $
- $ [4,3,5,2,1] $ $ \rightarrow $ $ [3,4,2,1,5] $ $ \rightarrow $ $ [3,2,1,4,5] $
- $ [4,5,3,2,1] $ $ \rightarrow $ $ [4,3,2,1,5] $ $ \rightarrow $ $ [3,2,1,4,5] $
- $ [5,3,4,2,1] $ $ \rightarrow $ $ [3,4,2,1,5] $ $ \rightarrow $ $ [3,2,1,4,5] $
- $ [5,4,3,2,1] $ $ \rightarrow $ $ [4,3,2,1,5] $ $ \rightarrow $ $ [3,2,1,4,5] $
So after exactly $ 2 $ times of swap they will all become $ a=[3,2,1,4,5] $ , whose value sequence is $ v=[0,1,2,0,0] $ .