Is Palindrome?

4.8

8 votes
String, Lazy Propagation in Interval/Segment Trees, Data Structures, Advanced Data Structures
Problem

Suppose you are given a string  of size  consisting of lowercase letters only. You will be given  queries. Each query can be of below two types:

  •     From  to , change characters in the string  to , i.e., make   
  •     Suppose string  is the substring of string  from index  to , or,  

For each query of type  answer will be Yes, if we can rearrange the characters in the string  so that the string becomes a palindrome. Otherwise, the answer is No.

Do note that query  makes permanent changes to the string , i.e., for all queries after it, the string is modified.

For each query of type , you don't make changes to the string . Or in other words, the string remains the same after query of type .

It is recommended to use Fast I/O.

Input Format

  • The first line contains a string  of size .
  • The second line contains one integer  - number of queries. Then  queries follow.
  • Each query will be of one of the two types as explained above.

Output Format

For each query of type , output the answer in a separate line.

Constraints

  • In each query,  will always follow.
  • In each query of type  will always follow.
  • The string  consists of lowercase letters only.
  • It is guaranteed that there will be at least  query of type .

 

Sample Input
abcsjakj
7
1 4 7 z
2 6 8
1 2 5 a
1 3 4 f
2 3 6
2 3 7
2 1 1
Sample Output
Yes
No
Yes
Yes
Time Limit: 2.5
Memory Limit: 256
Source Limit:
Explanation

The given string is .

  • After the first query, the string becomes 
  • The second query considers the substring .  Let's say this is denoted by . In this string, characters can be rearranged such that  becomes , which is a palindrome. Therefore the answer to this query is .
  • After the third query, the string becomes .
  • After the fourth query, the string becomes .
  • The fifth query considers the substring .  It can be shown that, this substring can't be converted into a palindrome. Therefore the answer to this query is .
  • The sixth query considers the substring .  Let's say this is denoted by . We can see that the string  is a palindrome. Therefore the answer to this query is .
  • The seventh query considers the substring .  A string of size 1 is always a palindrome. Therefore the answer to this query is .
Editor Image

?