QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#7766. 栞

Statistics

给定 $ n,k $,设 $ p $ 是一个 $ n $ 阶排列,你可以将 $ p $ 划分成恰好 $ k $ 个非空连续段(也即,选择 $ k-1 $ 个断点 $ 1\le x_1 < x_2 < \cdots < x_{k-1} < n $,令划分为 $ [1, x_1], (x_1, x_2], \cdots, (x_{k-1}, n] $),然后将每段内部的数从小到大排序,得到一个新的排列 $ q $。

定义 $ f(p) $ 表示,所有划分方案里可能得到的 $ q $ 中字典序最小的那一个。

现在给定一个 $ n $ 阶排列 $ q $,求有多少个 $ n $ 阶排列 $ p $ 的 $ f(p)=q $。请输出答案模 $ 998244353 $ 的值。

输入格式

第一行两个数 $ n,k $。

第二行 $ n $ 个数,表示排列 $ q $。

输出格式

一行一个数,表示答案。

样例

样例 1
2 1
1 2
2
样例 2
3 3
3 1 2
1
样例 3
6 3
1 2 3 6 5 4
13

数据范围

对于所有数据,$ 1\le n\le 500,1\le k \le n $。

子任务 1(10%):$ n\le 6 $。

子任务 2(20%):$ n\le 10 $。

子任务 3(30%):$ q=(1,2,\cdots,n) $。

子任务 4(40%):无特殊限制。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.