#P3757. [CQOI2017] 老C的键盘
[CQOI2017] 老C的键盘
Description
Lao C is a programmer.
As an excellent programmer, Lao C owns a distinctive keyboard, which is said to greatly increase the speed of writing programs and, driven by some mysterious power, make the programs run very fast.
Little Q is also a programmer. One day he sneaked into Lao C's home to see what was so special about the keyboard. He found that the keyboard has keys. Although these keys are neatly arranged in a single row, the height of each key is different. The clever Little Q immediately represented the height of each key with the integers , obtaining a permutation of .
In order to later build an imitation keyboard (the heights of its keys also form a permutation of ), and also to avoid being exactly the same as Lao C's keyboard, Little Q decided to record several pairs of height relations between keys. As a programmer, Little Q of course did not just pick a few pairs at random, but chose them in a very regular way: for , Little Q recorded a character '<' or '>', indicating or . Thus, Little Q obtained a string of length and happily went home.
Now Little Q wants to know how many keyboards satisfy the height relations he recorded. Although Little Q does not want his keyboard to be completely identical to Lao C's, the completely identical one also counts as satisfying the requirement. The answer may be large; you only need to tell Little Q the result modulo .
Input Format
The input consists of a single line containing a positive integer and a string of length consisting only of '<' and '>', representing the number of keys on the keyboard and the information recorded by Little Q, separated by a space.
Output Format
Output a single line containing an integer, the answer modulo .
5 <>><
3
5 <<<<
8
5 <<>>
18
Hint

Translated by ChatGPT 5
京公网安备 11011102002149号