Given a string S , of length N (contains parenthesis ) , and Q queries, in each query L and R be two indexes of string find the length of the longest balanced substring between L to R.

Ex : S = ( ( ) ) ( ) ( ) ( ( ( )

Q = 2

L = 1 , R = 4 answer = 4

L = 4 , R = 9 answer = 4

Help @galencolin @everule1 @chaudhary_19 @aneee004 @udayan14 @spaanse @ay2306 @ssjgz @dvyn01 @souradeep1999 @samarth2017

How to solve this using BIT .

I solved this : “https://codeforces.com/contest/380/problem/C” [Subsequence] , but don’t know how to solve above ?

And If anyone find out same question above then please share , as I google and only find subsequence variant .