当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6320:Problem B. Cut The String

题目描述
A string is palindromic if it reads the same from left to right.
Given a string $S[1..n]$, Little Q will ask you $m$ queries. For each query, Little Q will give you $2$ integers $l_i,r_i$, you need to find the number of ways to cut the continous substring $S[l_i..r_i]$ into two non-empty palindromic strings. That is, find the number of $k(l_i\leq k<r_i)$ satisfying $S[l_i..k]$ and $S[k+1..r_i]$ are both palindromic strings.
输入解释
The first line of the input contains an integer $T(1\leq T\leq10)$, denoting the number of test cases.
In each test case, there are $2$ integers $n,m(2\leq n\leq 100000,1\leq m\leq 100000)$ in the first line, denoting the length of $S$ and the number of queries.
In the next line, there is a string $S$ consists of $n$ lower-case English letters.
Then in the following $m$ lines, there are $2$ integers $l_i,r_i(1\leq l_i<r_i\leq n)$ in each line, denoting a query.
输出解释
For each query, print a single line containing an integer, denoting the answer.
输入样例
1
10 5
aaaabababb
1 4
1 5
4 9
6 10
1 10
输出样例
3
1
3
1
0
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6320

最后修改于 2020-10-25T23:30:16+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 524288/524288K(Java/Others)