CF629C.Famil Door and Brackets

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

As Famil Door’s birthday is coming, some of his friends (like Gabi) decided to buy a present for him. His friends are going to buy a string consisted of round brackets since Famil Door loves string of brackets of length nn more than any other strings!

The sequence of round brackets is called valid if and only if:

  1. the total number of opening brackets is equal to the total number of closing brackets;
  2. for any prefix of the sequence, the number of opening brackets is greater or equal than the number of closing brackets.

Gabi bought a string ss of length mm ( m<=nm<=n ) and want to complete it to obtain a valid sequence of brackets of length nn . He is going to pick some strings pp and qq consisting of round brackets and merge them in a string p+s+qp+s+q , that is add the string pp at the beginning of the string ss and string qq at the end of the string ss .

Now he wonders, how many pairs of strings pp and qq exists, such that the string p+s+qp+s+q is a valid sequence of round brackets. As this number may be pretty large, he wants to calculate it modulo 109+710^{9}+7 .

输入格式

First line contains nn and mm ( 1<=m<=n<=100000,nm<=20001<=m<=n<=100000,n-m<=2000 ) — the desired length of the string and the length of the string bought by Gabi, respectively.

The second line contains string ss of length mm consisting of characters '(' and ')' only.

输出格式

Print the number of pairs of string pp and qq such that p+s+qp+s+q is a valid sequence of round brackets modulo 109+710^{9}+7 .

输入输出样例

  • 输入#1

    4 1
    (
    

    输出#1

    4
    
  • 输入#2

    4 4
    (())
    

    输出#2

    1
    
  • 输入#3

    4 3
    (((
    

    输出#3

    0
    

说明/提示

In the first sample there are four different valid pairs:

  1. p=p= "(", q=q= "))"
  2. p=p= "()", q=q= ")"
  3. p=p= "", q=q= "())"
  4. p=p= "", q=q= ")()"

In the second sample the only way to obtain a desired string is choose empty pp and qq .

In the third sample there is no way to get a valid sequence of brackets.

首页