#P7879. 「SWTR-7」How to AK NOI?

    ID: 8277 远端评测题 1000~4500ms 512MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>动态规划 DP线段树2021后缀自动机 SAMO2优化矩阵加速哈希 hashing洛谷月赛

「SWTR-7」How to AK NOI?

Background

Some definitions and conventions about strings are explained in the “Help / Hint” section.

Please do not maliciously exploit the judge.


Xiao A is reading an article — “How to AK NOI Elegantly?”.

Problem Description

Unfortunately, this article is written in English. Xiao A has very poor eyesight, and his vocabulary is also very small.

Specifically, this article can be represented by a string tt. Another string ss is given: every word that Xiao A knows is a substring of ss with length at least kk.

A text segment TT is called “readable” if and only if it can be split into several words that Xiao A can understand. For example, when k=2k=2 and s=abcds=\texttt{abcd}, abcd/abc\texttt{abcd/abc} and cd/ab/bc/bcd\texttt{cd/ab/bc/bcd} are readable, while abcc\texttt{abcc} and tzcaknoi\texttt{tzcaknoi} are not readable.

Next, Xiao A will perform qq actions:

  • Type 1: Rub his eyes. Specifically, Xiao A chooses a substring t[l:r]t[l:r] of the article tt and modifies it into a string x (x=rl+1)x\ (|x|=r-l+1).
  • Type 2: Read the article. Specifically, Xiao A chooses a substring t[l:r]t[l:r] of the article tt and reads it. For each Type 2 operation, you need to tell Xiao A whether he can understand this text segment. If he can understand it, output Yes; otherwise output No.

Input Format

The first line contains a positive integer TT, indicating the Subtask ID for this test point.
The second line contains a string ss.
The third line contains a string tt.
The fourth line contains a positive integer kk.
The fifth line contains a positive integer qq.

The next qq lines each describe one query. First, an operation parameter opop is given:

  • If op=1op=1, then two positive integers l,rl,r and a string xx follow, meaning to modify t[l:r]t[l:r] into xx.
  • If op=2op=2, then two positive integers l,rl,r follow, meaning one query.

Output Format

For each query, output one line: if it is readable, output Yes; otherwise output No.

0
bbccabcacbcbac
cbcacbcabbcabca
3
17
2 1 2
2 1 4
2 1 6
2 2 15
2 6 15
2 9 15
1 4 13 babbccabbd
2 1 11
2 1 12
2 1 15
2 5 11
1 13 15 cab
2 3 12
2 7 10
2 11 15
2 10 14
2 9 14
No
No
Yes
Yes
Yes
Yes
Yes
No
No
No
No
Yes
No
No
Yes

Hint

“Constraints and Conventions”

Let n=sn=|s|, m=tm=|t|, L=xL=\sum |x|.

Subtask nn\leq mm\leq LL\leq qq\leq kk\leq Score
0 0 point
1 7070 7070 10 points
2 200200 200200
3 10310^3 10310^3
4 11
5 2×1052\times 10^5 10510^5 00 2×1042\times 10^4 55 15 points
6 5×1045\times 10^4 10 points
7 66 15 points
8 20 points

For 100%100\% of the data: 1n3×1061\leq n\leq 3\times 10^6, 1L3×1051\leq L\leq 3\times 10^5, 1m2×1051\leq m\leq 2\times 10^5, 1q1051\leq q\leq 10^5, 1k81\leq k\leq 8. It is guaranteed that x=rl+1|x|=r-l+1, and the character set is [a,i][\texttt{a,i}].


Subtask 0 contains the sample and Hack testdata.

  • Subtask 0 ~ 3: time limit 1s.
  • Subtask 4 ~ 6: time limit 1.5s.
  • Subtask 7: time limit 3s.
  • Subtask 8: time limit 4.5s.

“Subtask Dependencies”

This problem uses subtask dependencies.

Simply put, if Subtask a depends on Subtask b, then Subtask a will be counted toward the total score only when you pass all test points of Subtask b.

  • Subtask 1 depends on Subtask 0.
  • Subtask 2 depends on Subtask 0,1.
  • Subtask 3 depends on Subtask 0,1,2.
  • Subtask 6 depends on Subtask 0,5.
  • Subtask 7 depends on Subtask 0,5,6.
  • Subtask 8 depends on Subtask 0~7.

It is guaranteed that the Hack testdata of Subtask 0 satisfies all constraints of Subtask 1,2,3,6,7,8.

“Help / Hint”

A string tt' is a substring of tt if and only if we can delete some characters (possibly none) from the beginning and the end of tt and obtain tt'.
Define t[l:r]t[l:r] as the string formed by tltl+1tr1trt_lt_{l+1}\cdots t_{r-1}t_r.

The input file is large, so please pay attention to IO optimization.

“Source”

Sweet Round 07 E.
idea & solution & data: Alex_Wei; problem checking: tzc_wk.

Translated by ChatGPT 5