atcoder#ABC223F. [ABC223F] Parenthesis Checking

[ABC223F] Parenthesis Checking

Score : 500500 points

Problem Statement

Let us define a correct parenthesis sequence as a string that satisfies one of the following conditions.

  • It is an empty string.
  • It is a concatenation of (, AA, ), in this order, for some correct parenthesis sequence AA.
  • It is a concatenation of AA, BB, in this order, for some correct parenthesis sequences AA and BB.

We have a string SS of length NN consisting of ( and ).

Given QQ queries $\text{Query}_1,\text{Query}_2,\ldots,\text{Query}_Q$, process them in order. There are two kinds of queries, with the following formats and content.

  • 1 l r: Swap the ll-th and rr-th characters of SS.
  • 2 l r: Determine whether the contiguous substring from the ll-th through the rr-th character is a correct parenthesis sequence.

Constraints

  • 1N,Q2×1051 \leq N,Q \leq 2 \times 10^5
  • SS is a string of length NN consisting of ( and ).
  • 1l<rN1 \leq l < r \leq N
  • N,Q,l,rN,Q,l,r are all integers.
  • Each query is in the format 1 l r or 2 l r.
  • There is at least one query in the format 2 l r.

Input

Input is given from Standard Input in the following format:

NN QQ

SS

Query1\text{Query}_1

Query2\text{Query}_2

\vdots

QueryQ\text{Query}_Q

Output

For each query in the format 2 l r, print Yes if the contiguous substring is a correct parenthesis sequence, and No otherwise, followed by a newline.

5 3
(())(
2 1 4
2 1 2
2 4 5
Yes
No
No

In the first query, (()) is a correct parenthesis sequence.

In the second query, (( is not a correct parenthesis sequence.

In the third query, )( is not a correct parenthesis sequence.

5 3
(())(
2 1 4
1 1 4
2 1 4
Yes
No

In the first query, (()) is a correct parenthesis sequence.

In the second query, SS becomes )()((.

In the third query, )()( is not a correct parenthesis sequence.

8 8
(()(()))
2 2 7
2 2 8
1 2 5
2 3 4
1 3 4
1 3 5
1 1 4
1 6 8
Yes
No
No