Palindrome

Time Limit: 6000ms
Memory Limit: 65536KB
This problem will be judged on HDU. Original ID: 3856
64-bit integer IO format: %I64d      Java class name: Main

Description

Given a string S,you are asked to find the longest palindrome in the substring [l,r].

Input

The first line is a number T which indicates the number of test cases

then follows a string s(length(s)<200000)
s can consists all ascii characters
Then an integer q,q querys(q<200000)
each query is two integer l,r.
find the longest palindrome in the substring [l,r].

Output

the answer for each query.

Sample Input

1
aaabbcc
5
1 7
1 4
2 3
4 5
2 5

Sample Output

3
3
2
2
2

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .