|
||||||||||
K-th occurrenceTime Limit: 3000/3000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 4000 Accepted Submission(s): 1134 Problem Description 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. Input 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$. Output 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. Sample Input
Sample Output
Source | ||||||||||
|