#P7879. Readable Text Queries
Readable Text Queries
Readable Text Queries
In this problem, you are given an article represented by a string and another string . Little A only recognizes words that are substrings of of length at least . A text is called readable if and only if it can be segmented into one or more words that little A understands. Formally, a text is readable if there exists a segmentation [ T = w_1 w_2 \cdots w_m \quad (m \ge 1), ] such that for each , the word is a substring of with ( |w_i| \ge k ).
You will process operations on the article . There are two types of operations:
-
Type 1 (Update): Given indices and (1-indexed) and a string (with ( |x| = r-l+1 )), replace the substring with .
-
Type 2 (Query): Given indices and , check whether the substring is readable. Output
Yes
if it is readable, andNo
otherwise.
Note: In all operations, indices are 1-indexed.
Example: Let , . Then:
- The string
abcd
is readable (it is itself a substring of $s$). - The string
abc
is readable. - The string
cdab
is readable since it can be segmented ascd
/ab
. - The string
ab
is not readable if it cannot be segmented such that each segment has length at least $2$.
Your task is to simulate these operations and answer each query accordingly.
inputFormat
The input is given as follows:
op1 p1 p2 [x] op2 p1 p2 ... (q operations total)
Here,
- The first line contains the initial article string $t$.
- The second line contains the string $s$.
- The third line contains an integer $k$.
- The fourth line contains an integer $q$, the number of operations.
- Each of the next $q$ lines describes an operation. An operation starts with an integer describing its type.
- If the type is 1, it is followed by two integers $l$ and $r$ and a string $x$ (with length $r-l+1$).
- If the type is 2, it is followed by two integers $l$ and $r$.
All indices are 1-indexed.
outputFormat
For each operation of Type 2, output a single line containing either Yes
if the specified substring is readable, or No
otherwise.
sample
abc
abcd
2
3
2 1 3
1 2 3 xx
2 1 3
Yes
No
</p>