The 7th(2012) ACM Programming Contest of HUST - Onsite Contest(Semilive)
From: 2012-12-16 12:10:00
To: 2012-12-16 17:10:00
Now: 2017-09-20 01:10:38
J - Lexicographically Maximum Subsequence
Time Limit: 2s
Memory Limit: 128MB
Submissions: 303 Solved: 57
- You've got string S and m queries. Each query asks you to calculate the hash value for the lexicographically maximum subsequence of substring S[l….r].
We'll call a non-empty string S[p1p2... pk] = sp1sp2... spk(1 ≤ p1 < p2 < ... < pk ≤ |s|) a subsequence of string s = s1s2... s|s|.
String x = x1x2... x|x| is lexicographically larger than string y = y1y2... y|y|, if either |x| > |y| and x1 = y1, x2 = y2, ... , x|y| = y|y|, or exists such number r (r < |x|, r < |y|), that x1 = y1, x2 = y2, ... , xr = yr and xr + 1 > yr + 1. Characters in lines are compared like their ASCII codes.
The hash value for string s of length n is .
- There are multiple cases, process to the EOF. Each cases begins with a line contains a non-empty string s, consisting only of lowercase English letters. The string's length doesn't exceed 10^6. The second line contains an integer m(1<=m<=10^6), indicate that there are m queries. Then the next m lines contains m queries, each line describe the query with two integer l and r.
- Print the hash value of lexicographically maximum subsequence of string sfor each query in separate line.
- Sample Input
- Sample Output
- The 7th(2012) ACM Programming Contest of HUST
Problem Setter: Shucheng Zhong