#P3757. [CQOI2017] 老C的键盘

    ID: 1343 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划,dp2017重庆线段树各省省选树形 dp前缀和

[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 nn keys. Although these nn 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 1n1 \sim n, obtaining a permutation h1,h2,,hnh_1, h_2, \cdots , h_n of 1n1 \sim n.

In order to later build an imitation keyboard (the heights of its keys also form a permutation of 1n1 \sim n), 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 i=2,3,,ni=2,3, \cdots ,n, Little Q recorded a character '<' or '>', indicating hi2<hih_{\frac i2}<h_i or hi2>hih_{\frac i2}>h_i. Thus, Little Q obtained a string of length n1n-1 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 1,000,000,0071,000,000,007.

Input Format

The input consists of a single line containing a positive integer nn and a string of length n1n - 1 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 1,000,000,0071,000,000,007.

5 <>><
3
5 <<<<
8
5 <<>>
18

Hint

Translated by ChatGPT 5