#abc285f. F - Substring of Sorted String

F - Substring of Sorted String

Score : 500500 points

问题描述

你将获得一个长度为 NN 的由小写英文字母组成的字符串 SS,以及 QQ 个查询。请按照顺序处理这些查询。

每个查询属于以下两种类型之一:

  • 1 x c:将 SS 中的第 xx 个字符替换为字符 cc
  • 2 l r:对 SS 中的字符进行升序排序得到字符串 TT。如果 SS 中从第 ll 个到第 rr 个字符组成的子串是 TT 的子串,则输出 Yes;否则输出 No

什么是子串?子串是指通过从 SS 中移除 00 个或多个首部字符及 00 个或多个尾部字符后得到的字符串。例如,ababc 的子串,而 ac 不是 abc 的子串。

以上为通义千问 qwen-max 翻译,仅供参考。

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 SS is a string obtained by removing 00 or more initial characters and 00 or more final characters of SS. 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.

Sample Input 1

6
abcdcf
4
2 1 3
2 2 6
1 5 e
2 2 6

Sample Output 1

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.

update @ 2024/3/10 11:56:13