CF963D.Frequency of String

省选/NOI-

通过率:0%

时间限制:1.50s

内存限制:512MB

AC君温馨提醒

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

题目描述

You are given a string ss. You should answer nn queries. The ii-th query consists of integer kik_i and string mim_i. The answer for this query is the minimum length of such a string tt that tt is a substring of ss and mim_i has at least kik_i occurrences as a substring in tt.

A substring of a string is a continuous segment of characters of the string.

It is guaranteed that for any two queries the strings mim_i from these queries are different.

给你一个字符串 ss。你需要回答 nn 个查询。第 ii 个查询包含一个整数 kik_i 和一个字符串 mim_i。该查询的答案是满足以下条件的字符串 tt 的最小长度:tt 是 ss 的一个子串,且 mim_i 在 tt 中作为子串至少出现 kik_i 次。

字符串的子串是指该字符串中连续的一段字符。

保证对于任意两个查询,它们对应的字符串 mim_i 均不相同。

输入格式

The first line contains string ss (1≤∣s∣≤105)(1 \leq \left | s \right | \leq 10^{5}).

The second line contains an integer nn (1≤n≤1051 \leq n \leq 10^5).

Each of next nn lines contains an integer kik_i (1≤ki≤∣s∣)(1 \leq k_i \leq |s|) and a non-empty string mim_i — parameters of the query with number ii, in this order.

All strings in input consists of lowercase English letters. Sum of length of all strings in input doesn't exceed 10510^5. All mim_i are distinct.

第一行包含字符串 ss(1≤∣s∣≤1051 \leq \left | s \right | \leq 10^{5})。

第二行包含一个整数 nn(1≤n≤1051 \leq n \leq 10^5)。

接下来的 nn 行中,每行包含一个整数 kik_i(1≤ki≤∣s∣1 \leq k_i \leq |s|)和一个非空字符串 mim_i —— 分别为第 ii 个查询的参数,顺序如此。

输入中的所有字符串均由小写英文字母组成。输入中所有字符串的长度之和不超过 10510^5。所有 mim_i 互不相同。

输出格式

For each query output the answer for it in a separate line.

If a string mim_{i} occurs in ss less that kik_{i} times, output -1.

对于每个查询,请在单独一行中输出其答案。

如果字符串 mim_{i} 在 ss 中出现次数少于 kik_{i} 次,则输出 -1。

输入输出样例

  • 输入#1

    aaaaa
    5
    3 a
    3 aa
    2 aaa
    3 aaaa
    1 aaaaa

    输出#1

    3
    4
    4
    -1
    5
  • 输入#2

    abbb
    7
    4 b
    1 ab
    3 bb
    1 abb
    2 bbb
    1 a
    2 abbb

    输出#2

    -1
    2
    -1
    3
    -1
    1
    -1

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

首页