PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#FT0000179. Xâu nhị phân xen kẽ (Alternating String)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Xâu nhị phân xen kẽ (Alternating String)

Alternating String

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

Let SS be a binary string of length NN. A string is alternating when each pair of adjacent characters differs; a one-character string is always alternating. Process QQ commands. 1 L R flips every bit in the inclusive range [L,R][L,R]. 2 L R checks whether the current contiguous substring S[L…R]S[L\ldots R] is alternating. Flips accumulate in chronological order.

Input

The first line contains N,QN,Q; the second contains a length-NN binary string SS; the following QQ lines contain 1 L R or 2 L R.

Output

For every type-2 query, print exactly Yes if the substring is alternating and No otherwise.

Subtasks

  • Subtask 1 (20 points): 1≤N≤301\le N\le 30; 1≤Q≤1001\le Q\le 100; SS is a binary string of length NN; each command is 1 L R or 2 L R with 1≤L≤R≤N1\le L\le R\le N; at least one query of type 2.
  • Subtask 2 (30 points): 1≤N≤40001\le N\le 4000; 1≤Q≤60001\le Q\le 6000; SS is a binary string of length NN; each command is 1 L R or 2 L R with 1≤L≤R≤N1\le L\le R\le N; at least one query of type 2.
  • Subtask 3 (50 points): 1≤N≤5000001\le N\le 500000; 1≤Q≤5000001\le Q\le 500000; SS is a binary string of length NN; each command is 1 L R or 2 L R with 1≤L≤R≤N1\le L\le R\le N; at least one query of type 2.

Examples

Example 1

Input

5 6
10100
2 1 3
2 1 5
1 1 4
2 1 5
1 3 3
2 2 4

Output

Yes
No
Yes
No

Explanation

  1. 2 1 3: substring 101; equal adjacent boundary indices none; print Yes.
  2. 2 1 5: substring 10100; equal adjacent boundary indices [4]; print No.
  3. 1 1 4: flip positions 1 through 4: 10100 → 01010. No output.
  4. 2 1 5: substring 01010; equal adjacent boundary indices none; print Yes.
  5. 1 3 3: flip positions 3 through 3: 01010 → 01110. No output.
  6. 2 2 4: substring 111; equal adjacent boundary indices [2, 3]; print No.

Example 2

Input

1 2
1
1 1 1
2 1 1

Output

Yes

Explanation

  1. 1 1 1: flip positions 1 through 1: 1 → 0. No output.
  2. 2 1 1: substring 0; equal adjacent boundary indices none; print Yes.