6880.Palindrome Queries

Time Limit: 1s Memory Limit: 512MB

You are given a string that consists of $n$ characters between a–z. The positions of the string are indexed $1,2,\dots,n$ .

Your task is to process $m$ operations of the following types:

Change the character at positionktoxCheck if the substring from positionato positionbis a palindrome

Input Format(From the terminal/stdin)

The first input line has two integers $n$ and $m$ : the length of the string and the number of operations.

The next line has a string that consists of $n$ characters.

Finally, there are $m$ lines that describe the operations. Each line is of the form "1 $k$ $x$ " or "2 $a$ $b$ ".

  • $1 \le n, m \le 2 \cdot 10^5$
  • $1 \le k \le n$
  • $1 \le a \le b \le n$

Output Format(To the terminal/stdout)

For each operation 2, print YES if the substring is a palindrome and NO otherwise.

Sample Input

Copy
7 5
aybabtu
2 3 5
1 3 x
2 3 5
1 5 x
2 3 5
 · \n
       \n
 · · \n
 · · \n
 · · \n
 · · \n
 · · \n

Sample Output

Copy
YES
NO
YES
   \n
  \n
   \n
Source: CSES, String Algorithms, 2420

Submit

请先 登录

© 2025 FAQs