题库练习 Three Minimums
← 上一题 下一题 →

A14898 | Three Minimums

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Given a list of distinct values, we denote with first minimum, second minimum, and third minimum the three smallest values (in increasing order).

A permutation $p_1, p_2, \dots, p_n$ is good if the following statement holds for all pairs $(l,r)$ with $1\le l < l+2 \le r\le n$ .

- If $\{p_l, p_r\}$ are (not necessarily in this order) the first and second minimum of $p_l, p_{l+1}, \dots, p_r$ then the third minimum of $p_l, p_{l+1},\dots, p_r$ is either $p_{l+1}$ or $p_{r-1}$ .

You are given an integer $n$ and a string $s$ of length $m$ consisting of characters "<" and ">".

Count the number of good permutations $p_1, p_2,\dots, p_n$ such that, for all $1\le i\le m$ ,

- $p_i < p_{i+1}$ if $s_i =$ "<";
- $p_i > p_{i+1}$ if $s_i =$ ">".

As the result can be very large, you should print it modulo $998\,244\,353$ .

输入格式

The first line contains two integers $n$ and $m$ ( $2 \le n \le 2 \cdot 10^5$ , $1 \leq m \leq \min(100, n-1)$ ).

The second line contains a string $s$ of length $m$ , consisting of characters "<" and ">".

输出格式

Print a single integer: the number of good permutations satisfying the constraints described in the statement, modulo $998\,244\,353$ .

输入输出样例

输入 #1
5 3
>>>
输出 #1
5
输入 #2
5 1
<
输出 #2
56
输入 #3
6 5
<<><>
输出 #3
23
输入 #4
10 5
><<><
输出 #4
83154
输入 #5
1008 20
<><<>>><<<<<>>>>>>>>
输出 #5
284142857
C++ 编辑器
输入
输出