AT_abc477_c.Range Search Query

普及-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given strings SS and TT.
Process QQ queries.
In each query, you are given LL and RR. Determine whether the substring of SS consisting of the LL-th through RR-th characters contains TT as a substring.

What is a substring? A substring of SS is a string obtained by deleting zero or more characters from the beginning and zero or more characters from the end of SS.
For example, ab is a substring of abc, but ac is not a substring of abc.

给你两个字符串 SS 和 TT。
你需要处理 QQ 个查询。
对于每个查询,给定 LL 和 RR,判断 SS 中从第 LL 个字符到第 RR 个字符构成的子串是否包含 TT 作为其子串。

什么是子串?字符串 SS 的一个子串是指通过从 SS 的开头删除零个或多个字符、并从 SS 的末尾删除零个或多个字符后所得到的字符串。
例如,ab 是 abc 的子串,但 ac 不是 abc 的子串。

输入格式

The input is given from Standard Input in the following format:

QQ
SS
TT
query1\mathrm{query}_1
query2\mathrm{query}_2
⋮\vdots
queryQ\mathrm{query}_Q

Each query queryq\mathrm{query}_q is given in the following format:

LL RR

输入从标准输入中按以下格式给出:

QQ
SS
TT
query1\mathrm{query}_1
query2\mathrm{query}_2
⋮\vdots
queryQ\mathrm{query}_Q

每个查询 queryq\mathrm{query}_q 的格式如下:

LL RR

输出格式

Output QQ lines. The qq-th line should contain Yes if, for the qq-th query, the substring of SS consisting of the LL-th through RR-th characters contains TT as a substring, and No otherwise.

输出 QQ 行。对于第 qq 个查询,若字符串 SS 中从第 LL 个字符到第 RR 个字符构成的子串包含 TT 作为其子串,则第 qq 行输出 Yes,否则输出 No。

输入输出样例

  • 输入#1

    3
    abcdabc
    bc
    2 6
    3 5
    3 7

    输出#1

    Yes
    No
    Yes
  • 输入#2

    10
    bbbaaabbbaaaaaabbbab
    bbb
    5 16
    5 6
    2 16
    6 7
    17 19
    3 7
    7 16
    7 20
    17 19
    2 6

    输出#2

    Yes
    No
    Yes
    No
    No
    No
    Yes
    Yes
    No
    No

说明/提示

Sample 1 Explanation:
Consider the first query. The substring of SS consisting of the 22-nd through 66-th characters is bcdab. The substring of bcdab consisting of the 11-st through 22-nd characters matches TT, so bcdab contains TT. Thus, the answer is Yes.

Constraints

  • SS is a string of length between 11 and 4×1054 \times 10^5, inclusive, consisting of lowercase English letters.
  • TT is a string of length between 11 and 1010, inclusive, consisting of lowercase English letters.
  • 1≤Q≤2×1051 \leq Q \leq 2 \times 10^5
  • 1≤L≤R≤∣S∣1 \leq L \leq R \leq |S|
  • Q,L,RQ, L, R are integers.

样例 1 解释:
考虑第一个查询。字符串 SS 中第 22 个到第 66 个字符组成的子串为 bcdab。该子串 bcdab 中第 11 个到第 22 个字符组成的子串与 TT 相匹配,因此 bcdab 包含 TT。故答案为 Yes。

约束条件

  • SS 是一个长度在 11 到 4×1054 \times 10^5(含)之间的字符串,仅由小写英文字母组成。
  • TT 是一个长度在 11 到 1010(含)之间的字符串,仅由小写英文字母组成。
  • 1≤Q≤2×1051 \leq Q \leq 2 \times 10^5
  • 1≤L≤R≤∣S∣1 \leq L \leq R \leq |S|
  • Q,L,RQ, L, R 均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页