PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#FT0000181. Truy vấn xâu đối xứng (Palindrome Queries)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Truy vấn xâu đối xứng (Palindrome Queries)

Palindrome Queries

Source: CSES

Version: Phuoc Hung OJ Extended

Problem Statement

Given a lowercase English string SS of length NN, with 1-based positions, process QQ operations in order. Command 1 k x replaces the character at position kk by xx; it does not insert a new character. Command 2 a b checks whether the contiguous substring Sa…SbS_a\ldots S_b is a palindrome, meaning its forward and reversed readings are identical. Both endpoints are included, and previous updates affect all later queries.

Input

The first line contains N,QN,Q. The second contains the string SS of exactly NN lowercase characters. The next QQ lines are either 1 k x or 2 a b.

Output

For every type-2 query print YES if the substring is a palindrome, and NO otherwise. Output is case-sensitive.

Subtasks

  • Subtask 1 (20 points): 1≤N≤301\le N\le 30; 1≤Q≤601\le Q\le 60; SS has exactly NN lowercase English letters; each command is 1 x c with 1≤x≤N1\le x\le N, lowercase c, or 2 L R with 1≤L≤R≤N1\le L\le R\le N; at least one type-2 query in PHOJ tests.
  • Subtask 2 (30 points): 1≤N≤50001\le N\le 5000; 1≤Q≤50001\le Q\le 5000; SS has exactly NN lowercase English letters; each command is 1 x c with 1≤x≤N1\le x\le N, lowercase c, or 2 L R with 1≤L≤R≤N1\le L\le R\le N; at least one type-2 query in PHOJ tests.
  • Subtask 3 (50 points): 1≤N≤2000001\le N\le 200000; 1≤Q≤2000001\le Q\le 200000; SS has exactly NN lowercase English letters; each command is 1 x c with 1≤x≤N1\le x\le N, lowercase c, or 2 L R with 1≤L≤R≤N1\le L\le R\le N; at least one type-2 query in PHOJ tests.

Examples

Example 1

Input

7 5
aybabtu
2 3 5
1 3 x
2 3 5
1 5 x
2 3 5

Output

YES
NO
YES

Explanation

  1. 2 3 5: substring bab; reversed bab; print YES.
  2. 1 3 x: replace b by x at position 3; the string becomes ayxabtu. No output.
  3. 2 3 5: substring xab; reversed bax; print NO.
  4. 1 5 x: replace b by x at position 5; the string becomes ayxaxtu. No output.
  5. 2 3 5: substring xax; reversed xax; print YES.

Example 2

Input

5 5
abcba
2 1 5
1 1 z
2 1 5
1 3 z
2 2 4

Output

YES
NO
YES

Explanation

  1. 2 1 5: substring abcba; reversed abcba; print YES.
  2. 1 1 z: replace a by z at position 1; the string becomes zbcba. No output.
  3. 2 1 5: substring zbcba; reversed abcbz; print NO.
  4. 1 3 z: replace c by z at position 3; the string becomes zbzba. No output.
  5. 2 2 4: substring bzb; reversed bzb; print YES.