当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6704:K-th occurrence

题目描述
You are given a string $S$ consisting of only lowercase english letters and some queries.

For each query $(l, r, k)$, please output the starting position of the k-th occurence of the substring $S_lS_{l+1}...S_r$ in S.
输入解释
The first line contains an integer $T(1 \leq T \leq 20)$, denoting the number of test cases.

The first line of each test case contains two integer $N(1 \leq N \leq 10^5), Q(1 \leq Q \leq 10^5)$, denoting the length of $S$ and the number of queries.

The second line of each test case contains a string $S(|S|=N)$ consisting of only lowercase english letters.

Then $Q$ lines follow, each line contains three integer $l, r(1 \leq l \leq r \leq N)$ and $k(1 \leq k \leq N)$, denoting a query.

There are at most $5$ testcases which $N$ is greater than $10^3$.
输出解释
For each query, output the starting position of the k-th occurence of the given substring.

If such position don't exists, output $-1$ instead.
输入样例
2
12 6
aaabaabaaaab
3 3 4
2 3 2
7 8 3
3 4 2
1 4 2
8 12 1
1 1
a
1 1 1
输出样例
5
2
-1
6
9
8
1
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6704

最后修改于 2020-10-25T23:33:39+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000/3000MS(Java/Others) 524288/524288K(Java/Others)