Problem Statement
Give a string of length
consisting of only characters
(
and )
. Output the number of sub-sequences of which are equal to
()
.
This problem can be solved without divide and conquer, but for the purpose of this exercise, please use divide and conquer.
NOTE: A subsequence of is formed by deleting some characters from
.
Input Format
Your first line will contain a single integer .
Your next line will contain
.
Output Format
Output the number of bracket sequences equal to ()
in .
Constraints
Sample Cases
Input 1
5
((())
Output 1
6
Input 2
10
)()()(()()
Output 2
12
Template
n = int(input())
s = input()
# print your output
Comments