atcoder#ABC285F. [ABC285F] Substring of Sorted String

[ABC285F] Substring of Sorted String

Score : 500500 points

Problem Statement

You are given a string SS of length NN consisting of lowercase English letters, and QQ queries. Process the queries in order.

Each query is of one of the following two kinds:

  • 1 x c : replace the xx-th character of SS by the character cc.
  • 2 l r : let TT be the string obtained by sorting the characters of SS in ascending order. Print Yes if the string consisting of the ll-th through rr-th characters of SS is a substring of TT; print No otherwise.
What is a substring? A substring of S is a string obtained by removing 0 or more initial characters and 0 or more final characters of S. For example, ab is a substring of abc, while ac is not a substring of abc.

Constraints

  • 1N1051\leq N \leq 10^5
  • SS is a string of length NN consisting of lowercase English letters.
  • 1Q1051 \leq Q \leq 10^5
  • For each query of the first kind, 1xN1 \leq x \leq N.
  • For each query of the first kind, cc is a lowercase English letter.
  • For each query of the second kind, 1lrN1 \leq l \leq r \leq N.

Input

The input is given from Standard Input in the following format, where queryi\text{query}_i denotes the ii-th query:

NN

SS

QQ

query1\text{query}_1

query2\text{query}_2

\vdots

queryQ\text{query}_Q

Output

Process the queries as instructed in the Problem Statement.

6
abcdcf
4
2 1 3
2 2 6
1 5 e
2 2 6
Yes
No
Yes
  • In the 11-st query, abccdf is the string TT obtained by sorting the characters of SS in ascending order. The string abc, consisting of the 11-st through 33-rd characters of SS, is a substring of TT, so Yes should be printed.
  • In the 22-nd query, abccdf is the string TT obtained by sorting the characters of SS in ascending order. The string bcdcf, consisting of the 22-nd through 66-th characters of SS, is not a substring of TT, so No should be printed.
  • The 33-rd query sets the 55-th character of SS to e, making SS abcdef.
  • In the 44-th query, abcdef is the string TT obtained by sorting the characters of SS in ascending order. The string bcdef, consisting of the 22-nd through 66-th characters of SS, is a substring of TT, so Yes should be printed.