PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FT0000183. Truy vấn palindrome với cập nhật ký tự (Palindrome Query)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Truy vấn palindrome với cập nhật ký tự (Palindrome Query)
Palindrome Query
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Given a lowercase English string of length , process operations in order. 1 x c replaces the character at position by . 2 L R asks whether the contiguous substring from position to equals its own reverse. Updates take effect immediately for subsequent queries. All indices are 1-based and query intervals include both endpoints.
Input
The first line contains , followed by the string . Each of the next lines is 1 x c or 2 L R.
Output
For every type-2 command print exactly Yes for a palindrome and No otherwise.
Subtasks
- Subtask 1 (20 points): ; ; has exactly lowercase English letters; each command is
1 x cwith , lowercasec, or2 L Rwith ; at least one type-2 query in PHOJ tests. - Subtask 2 (30 points): ; ; has exactly lowercase English letters; each command is
1 x cwith , lowercasec, or2 L Rwith ; at least one type-2 query in PHOJ tests. - Subtask 3 (50 points): ; ; has exactly lowercase English letters; each command is
1 x cwith , lowercasec, or2 L Rwith ; at least one type-2 query in PHOJ tests.
Examples
Example 1
Input
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
Output
Yes
No
Yes
No
Yes
Yes
Explanation
2 1 5: substringabcba; reversedabcba; printYes.2 4 7: substringbacb; reversedbcab; printNo.2 2 2: substringb; reversedb; printYes.1 5 c: replaceabycat position 5; the string becomesabcbccb. No output.2 1 5: substringabcbc; reversedcbcba; printNo.2 4 7: substringbccb; reversedbccb; printYes.1 4 c: replacebbycat position 4; the string becomesabccccb. No output.2 3 6: substringcccc; reversedcccc; printYes.
Example 2
Input
4 4
aaaa
2 1 4
1 1 b
2 1 4
2 2 3
Output
Yes
No
Yes
Explanation
2 1 4: substringaaaa; reversedaaaa; printYes.1 1 b: replaceabybat position 1; the string becomesbaaa. No output.2 1 4: substringbaaa; reversedaaab; printNo.2 2 3: substringaa; reversedaa; printYes.