← All problemsSign in

Query on Brackets

You are given a sequence $S$ of brackets, consisting of characters "(" and ")". You need to perform $Q$ queries of two types. In type 1 query, each query is described by two integers $Li$, $Ri$ ( $1  \leq  Li \leq  Ri \leq  Size of sequence$ ). The answer to this query is the length of the maximum correct bracket subsequence of sequence $sLi$,  $sLi$+1, ..., $sRi$. In type 2 query

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start