#P7044. 「MCOI-03」括号

「MCOI-03」括号

Description

Define the level 00 deviation value of a bracket string as the minimum number of operations needed to modify this bracket string into a valid bracket sequence. In one operation, you can insert a bracket at some position or delete a bracket at some position.

For i (i>0)i\ (i>0), define the level ii deviation value of the string as the sum of the level i1i-1 deviation values over all substrings of this string.

Now you need to compute the level KK deviation value of a bracket string SS of length NN. The answer may be very large; output the result modulo 998244353998244353.

Input Format

The first line contains two integers N,KN, K.

The second line contains a string representing the bracket sequence SS.

Output Format

Output one integer, the answer modulo 998244353998244353.

3 1
(()
6
3 2
(()
15

Hint

Sample Explanation

For sample 11, the level 00 costs of all substrings of SS are:

  • (\texttt{(}, cost is 11.
  • (\texttt{(}, cost is 11.
  • )\texttt{)}, cost is 11.
  • ((\texttt{((}, cost is 22.
  • ()\texttt{()}, cost is 00.
  • (()\texttt{(()}, cost is 11.

The total is 1+1+1+2+0+1=61+1+1+2+0+1=6.

Constraints

This problem uses bundled testdata.

Subtask ID NN\le KK\le Score
11 55 33
22 5×1035\times 10^3 11 1010
33 10610^6 1212
44 10210^2 1010
55 5×1035\times10^3 5×1035\times 10^3 2020
66 10610^6 4545

For 100%100\% of the testdata, 1N,K1061 \le N, K \le 10^6.


Original idea: WAPER420

Translated by ChatGPT 5