일부 문자가 'x'로 가려진 문자열이 주어질 때, 어떤 올바른 괄호 기록의 한 연속 구간을 뒤집어 얻을 수 있는 길이 N 문자열의 개수를 센다.
어려움8동적 계획법조합론아직 제출이 없습니다시간 제한5초메모리 제한1536 MBDo you know Just Odd Inventions Co., Ltd.? The business of this company is doing “just odd inventions.” Here we just call it JOI Company.
There is a security gate installed in the doorway of JOI Company, in order to prevent confidential information leaks. One must pass through the gate when entering or exiting the company. It is impossible for two or more people to pass through the gate at the same time.
Whenever a person pass through this gate, it records the information indicating that a person enters or exits the company. Now, IOI-kun, an employee of JOI Company, has a record of the gate for some day. The record is represented by string S : if the i-th character of S is ‘(’, it means that the i-th person who passed through the gate entered the company, and if the i-th character of S is ‘)’, it means that the i-th person who passed through the gate exited the company. IOI-kun knows that there were no people inside JOI Company at the beginning or at the end of this day. Note that there exist strings consisting only of ‘(’ and ‘)’ which cannot represent a record: for example, a record cannot be ())( or (() because it would follow that the number of people inside JOI Company had become negative or there had been a person inside JOI Company at the end of the day, respectively.
The next moment IOI-kun checked the record, the string S was modified by a computer virus spread across JOI Company! After some investigation, he supposed that the modification took the following process:
IOI-kun does not remember S , so he tries to recover S from S′′. For that, he wants first to count the number of strings which can be S′ (not S , be careful).
Given string S′′, write a program which calculates the number of strings which can be S′, modulo 1 000 000 007.
Read the following data from the standard input.
Write one line to the standard output. The output should contain the number of strings which can be S′, modulo 1 000 000 007. If there is no such string, output 0.