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

Boring String Problem

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 3461    Accepted Submission(s): 932


Problem Description
In this problem, you are given a string s and q queries.

For each query, you should answer that when all distinct substrings of string s were sorted lexicographically, which one is the k-th smallest.

A substring si...j of the string s = a1a2 ...an(1 ¡Ü i ¡Ü j ¡Ü n) is the string aiai+1 ...aj. Two substrings sx...y and sz...w are cosidered to be distinct if sx...y ¡Ù Sz...w
 

Input
The input consists of multiple test cases.Please process till EOF.

Each test case begins with a line containing a string s(|s| ¡Ü 105) with only lowercase letters.

Next line contains a postive integer q(1 ¡Ü q ¡Ü 105), the number of questions.

q queries are given in the next q lines. Every line contains an integer v. You should calculate the k by k = (l¨’r¨’v)+1(l, r is the output of previous question, at the beginning of each case l = r = 0, 0 < k < 263, ¡°¨’¡± denotes exclusive or)
 

Output
For each test case, output consists of q lines, the i-th line contains two integers l, r which is the answer to the i-th query. (The answer l,r satisfies that sl...r is the k-th smallest and if there are several l,r available, ouput l,r which with the smallest l. If there is no l,r satisfied, output ¡°0 0¡±. Note that s1...n is the whole string)
 

Sample Input
aaa 4 0 2 3 5
 

Sample Output
1 1 1 3 1 2 0 0
 

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-04-19 04:01:01, Gzip enabled