#abc331f. F - Palindrome Query

F - Palindrome Query

Score : 525525 points

问题描述

你将得到一个长度为 NN 的由小写英文字母组成的字符串 SS
按照给定顺序处理 QQ 个查询。查询有两种类型:

  • 1 x c:将字符串 SS 中的第 xx 个字符更改为小写英文字母 cc
  • 2 L R:如果由字符串 SS 中从第 LL 个到第 RR 个字符组成的子串是一个回文串,则输出 Yes;否则,输出 No

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

Problem Statement

You are given a string SS of length NN consisting of lowercase English letters.
Process QQ queries described below in the order they are given.
There are two types of queries:

  • 1 x c : Change the xx-th character of SS to the lowercase English letter cc.
  • 2 L R : If the substring formed by the LL-th through RR-th characters of SS is a palindrome, print Yes; otherwise, print No.

Constraints

  • 1N1061 \leq N \leq 10^6
  • 1Q1051 \leq Q \leq 10^5
  • SS is a string of length NN consisting of lowercase English letters.
  • 1xN1 \leq x \leq N
  • cc is a lowercase English letter.
  • 1LRN1 \leq L \leq R \leq N
  • N,Q,x,L,RN, Q, x, L, R are integers.

Input

The input is given from Standard Input in the following format. Here, queryi\text{query}_i is the ii-th query to be processed.

NN QQ

SS

query1\text{query}_1

query2\text{query}_2

\vdots

queryQ\text{query}_Q

Each query is given in one of the following formats:

11 xx cc

22 LL RR

Output

Follow the instructions in the problem statement and print the answers to the queries, separated by newlines.

Sample Input 1

7 8
abcbacb
2 1 5
2 4 7
2 2 2
1 5 c
2 1 5
2 4 7
1 4 c
2 3 6

Sample Output 1

Yes
No
Yes
No
Yes
Yes

Initially, S=S = abcbacb.
For the first query, the string formed by the 11-st through 55-th characters of SS is abcba, which is a palindrome. Thus, print Yes.
For the second query, the string formed by the 44-th through 77-th character of SS is bacb, which is not a palindrome. Thus, print No.
For the third query, the string formed by the 22-nd through 22-nd character of SS is b, which is a palindrome. Thus, output Yes.
For the fourth query, change the 55-th character of SS to c. SS becomes abcbccb.
For the fifth query, the string formed by the 11-st through 55-th character of SS is abcbc, which is not a palindrome. Thus, output No.
For the sixth query, the string formed by the 44-th through 77-th character of SS is bccb, which is a palindrome. Thus, output Yes.
For the seventh query, change the 44-th character of SS to c. SS becomes abccccb.
For the eighth query, the string formed by the 33-rd through 66-th character of cccc, which is a palindrome. Thus, output Yes.

update @ 2024/3/10 01:16:08