#P6333. [COCI 2007/2008 #1] ZAPIS
[COCI 2007/2008 #1] ZAPIS
Problem Description
A regular bracket sequence is defined as follows:
-
The empty string is a regular bracket sequence.
-
If is a regular bracket sequence, then
(A),[A], and{A}are all regular bracket sequences. -
If and are both regular bracket sequences, then the sequence is also a regular bracket sequence.
Ivica found a string of length that seems to be a regular bracket sequence. However, some characters have become unclear and are represented by ?.
He wants you to help compute how many possible replacements make this string a regular bracket sequence.
Input Format
The first line contains an integer , which represents the length of this string.
The second line contains characters. Each character may be any of ? { } [ ] ( ).
Output Format
Output one integer on a single line, representing the total number of valid possibilities. Because the answer may be very large, you only need to output the last digits of the answer. (If it has fewer than digits, do not pad with leading .)
6
()()()
1
10
(?([?)]?}?
3
16
???[???????]????
92202
Hint
Explanation of Sample
All possible cases are: ({([()])}), ()([()]{}), ([([])]{}).
Constraints
For of the testdata, it is guaranteed that .
Note
This problem is translated from COCI2007-2008 CONTEST #1 T4 ZAPIS
Translated by ChatGPT 5