#FT0000180. Xâu con của xâu đã sắp xếp (Substring of Sorted String)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Xâu con của xâu đã sắp xếp (Substring of Sorted String)
Substring of Sorted String
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
You are given a lowercase string of length . Operation 1 x c replaces character by . For 2 l r, form by sorting the entire current string in nondecreasing alphabetical order. Decide whether the exact contiguous substring occurs as a contiguous substring somewhere in . Being nondecreasing by itself is insufficient if the interval omits occurrences of letters strictly between its endpoint letters.
Input
The first line contains ; the second line contains exactly lowercase letters forming ; the third line contains . Each of the last lines is 1 x c or 2 l r.
Output
For each type-2 query, print exactly Yes if the chosen substring occurs contiguously in the sorted string , and No otherwise.
Subtasks
- Subtask 1 (20 points): ; ; has length exactly with lowercase English letters; each command is
1 x c, andclowercase, or2 l r, ; at least one type-2 query in the PHOJ test set. - Subtask 2 (30 points): ; ; has length exactly with lowercase English letters; each command is
1 x c, andclowercase, or2 l r, ; at least one type-2 query in the PHOJ test set. - Subtask 3 (50 points): ; ; has length exactly with lowercase English letters; each command is
1 x c, andclowercase, or2 l r, ; at least one type-2 query in the PHOJ test set.
Examples
Example 1
Input
6
abcdcf
4
2 1 3
2 2 6
1 5 e
2 2 6
Output
Yes
No
Yes
Explanation
2 1 3: current sorted full string isabccdf; queried substringabcis present as a contiguous substring, so print Yes.2 2 6: current sorted full string isabccdf; queried substringbcdcfis absent as a contiguous substring, so print No.1 5 e: replace position 5:c→e; current stringabcdef. No output.2 2 6: current sorted full string isabcdef; queried substringbcdefis present as a contiguous substring, so print Yes.
Example 2
Input
3
abc
4
2 1 2
1 3 a
2 1 3
2 2 3
Output
Yes
No
No
Explanation
2 1 2: current sorted full string isabc; queried substringabis present as a contiguous substring, so print Yes.1 3 a: replace position 3:c→a; current stringaba. No output.2 1 3: current sorted full string isaab; queried substringabais absent as a contiguous substring, so print No.2 2 3: current sorted full string isaab; queried substringbais absent as a contiguous substring, so print No.