F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Kth Smallest Common Substring

Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 20    Accepted Submission(s): 3


Problem Description
Given $n (1 \leq n \leq 10^5)$ strings containing only lowercase letters, you need to find out the $k$th smallest one among all the distinct common substrings of the $n$ strings.
 

Input
This problem contains multiple test cases.

The first line contains an integer $T$ ($1 \leq T \leq 20$) indicating the number of test cases.

For each test case, the first line of the input contains an integer $n (1 \leq n \leq 10^5)$ indicates the number of the strings.

Each of the next $n$ lines contains a string containing only lowercase letters.

The next line contains an integer $q$, the number of the queries.

Each of the next $q (1 \leq q \leq 10^5)$ lines contains an integer $k (1 \leq k \leq 10^7)$ represeting a query.

It is guaranteed that for each test case, the sum of the length of all strings is no more than $2 \times 10 ^ 5$.
 

Output
For each query, you need to give an interval $[l,r)$ indicating the first(leftmost) occurrence of the answer in the first string.

If the number of distinct common substrings is less than k, output $-1$ instead.
 

Sample Input
1 5 abaaaa aabaab aabbba aabaaa abaabb 3 1 2 3
 

Sample Output
0 1 2 4 0 2
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 06:55:54, Gzip enabled