r/Competitive_Coding • u/[deleted] • Mar 08 '24
Please solve fast
This Lazy Problem setter, decided not to bore you with any story and directly come up to the point. You are given a string consisting of only a
s and b
s , you will have 3 types of queries:
Given 1 L R
all characters in range [L,R], change all a
s to b
s and b
s to a
s .Given 2 L R
, print YES
if every pair of adjecent characters in range [L,R]
is different.Given 3 L R
, print YES
if every pair of adjecent characters in range [L,R]
is same.
Note: since length 1 has no adjecent element, the answer for it will always be Yes
Input Format
First line contains a single integer N
denoting the length of string.Second line contains the string consisting of only a
and b
.Third line contains a single integer Q
denoting number of queries.Next Q lines contain 3 integers - Type, L, R
.
Output Format
For every Query of Type 2 and Type 3 , Print Yes
or No
respectively. Note That: print "Yes" with all capital and same goes for "No"
Constraints
1 ≤ N ≤ 2 X 10^5
string S consisting of only a
and b
of length N1 ≤ Q ≤ 2 X 10^5
1 ≤ Type ≤ 3
1 ≤ L ≤ R ≤ N
Sample 0
Input
5 ababb 8 2 1 3 2 1 5 1 1 4 2 1 5 1 3 3 2 2 4 3 1 3 3 1 1
Output
Yes No Yes No No Yes