Is Palindrome?
Practice
4.8 (8 votes)
String
Lazy propagation in interval/segment trees
Data structures
Advanced data structures
Problem
80% Success 1824 Attempts 50 Points 2.5s Time Limit 256MB Memory 1024 KB Max Code

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

  • \(1\) \(l\) \(r\) \(ch:\) From \(l\) to \(r\), change characters in the string \(s\) to \(ch\), i.e., make \(s[l] = s[l + 1] = \) \(...\) \(s[r] = ch\)
  • \(2\)  \(l\) \(r:\) Suppose string \(t\) is the substring of string \(s\) from index \(l\) to \(r\), or, \(t = \) \(s[l ... r]\)

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

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

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

It is recommended to use Fast I/O.

Input Format

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

Output Format

For each query of type \(2\), output the answer in a separate line.

Constraints

  • \(1 \leq n \leq 10^{5}\)
  • \(1 \leq q \leq 10^5\)
  • In each query, \(1 \leq l \leq r \leq n\) will always follow.
  • In each query of type \(1\)\(a \leq ch \leq z\) will always follow.
  • The string \(s\) consists of lowercase letters only.
  • It is guaranteed that there will be at least \(1\) query of type \(2\).

 

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:50
7 votes
Tags:
Advanced Data StructuresData StructuresXORHashing algorithmLazy Propagation in Interval/Segment TreesNumber theory
Points:50
3 votes
Tags:
Advanced Data StructuresData StructuresString AlgorithmsLazy Propagation in Interval/Segment TreesHashing algorithm
Points:50
Tags:
Hard
Editorial

Login to unlock the editorial