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
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Xâu nhị phân xen kẽ (Alternating String)
Alternating String
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Let be a binary string of length . A string is alternating when each pair of adjacent characters differs; a one-character string is always alternating. Process commands. 1 L R flips every bit in the inclusive range . 2 L R checks whether the current contiguous substring is alternating. Flips accumulate in chronological order.
Input
The first line contains ; the second contains a length- binary string ; the following 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): ; ; is a binary string of length ; each command is
1 L Ror2 L Rwith ; at least one query of type 2. - Subtask 2 (30 points): ; ; is a binary string of length ; each command is
1 L Ror2 L Rwith ; at least one query of type 2. - Subtask 3 (50 points): ; ; is a binary string of length ; each command is
1 L Ror2 L Rwith ; 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
2 1 3: substring101; equal adjacent boundary indices none; print Yes.2 1 5: substring10100; equal adjacent boundary indices [4]; print No.1 1 4: flip positions 1 through 4:10100→01010. No output.2 1 5: substring01010; equal adjacent boundary indices none; print Yes.1 3 3: flip positions 3 through 3:01010→01110. No output.2 2 4: substring111; 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: flip positions 1 through 1:1→0. No output.2 1 1: substring0; equal adjacent boundary indices none; print Yes.