CF909C Python Indentation

题目描述

CF909C Python的缩进 Python的代码中不需要写begin、end或者大括号去标记开头或结尾。 我们将考虑一种Python非常简化的子集,它的语句只有两种类型。 每行只写一个简单语句,比如赋值。 For语句是一个较复杂的语句,他们可能包含一个或多个其他的语句。 For语句由一个单独的行组成,以“For”前缀和循环体开头。 循环体是一个语句块,比循环头缩进一级。 循环体可以包含这两种类型的语句。循环体不能为空。 给你一个没有缩进的序列,求有多少种方式添加缩进可以形成一个完整的Python代码。

输入格式

第一行:N 接下来N行每行一个字符f(for语句)或s(简单语句)。 保证最后一行一定是s(简单语句)。

输出格式

输出方案数,答案对10^9+7取模。 感谢@2016c01 提供的翻译

说明/提示

In the first test case, there is only one way to indent the program: the second for statement must be part of the body of the first one. `

simple statement

for statement

for statement

simple statement

`In the second test case, there are two ways to indent the program: the second for statement can either be part of the first one's body or a separate statement following the first one. `

for statement

simple statement

for statement

simple statement

`or `

for statement

simple statement

for statement

simple statement

`