Strings in the Pocket(马拉车+字符串判断)

Posted wzl19981116

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Strings in the Pocket(马拉车+字符串判断)相关的知识,希望对你有一定的参考价值。

题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=6012
BaoBao has just found two strings s and in his left pocket, where indicates the -th character in string , and indicates the -th character in string .

As BaoBao is bored, he decides to select a substring of and reverse it. Formally speaking, he can select two integers and such that and change the string to .

In how many ways can BaoBao change to using the above operation exactly once? Let be an operation which reverses the substring , and be an operation which reverses the substring . These two operations are considered different, if or .

Input
There are multiple test cases. The first line of the input contains an integer , indicating the number of test cases. For each test case:

The first line contains a string (), while the second line contains another string (). Both strings are composed of lower-cased English letters.

It‘s guaranteed that the sum of of all test cases will not exceed .

Output
For each test case output one line containing one integer, indicating the answer.

Sample Input
2
abcbcdcbd
abcdcbcbd
abc
abc
Sample Output
3
3
Hint
For the first sample test case, BaoBao can do one of the following three operations: (2, 8), (3, 7) or (4, 6).

For the second sample test case, BaoBao can do one of the following three operations: (1, 1), (2, 2) or (3, 3).

题意就是,a要变成b,可以有多少种逆转做法;

分两种情况,1,如果两个相同,用马拉车求回文串数量就好,开longlong

2.找出不同的点坐标,然后看看这两个点坐标之间是不是逆转后相等,不是输出0,是的话,在往两边找出有多少种做法;

。。不知道为什么错了,换板子

以上是关于Strings in the Pocket(马拉车+字符串判断)的主要内容,如果未能解决你的问题,请参考以下文章

2019浙江省赛K zoj4110 Strings in the Pocket(manachar)

zoj4110 Strings in the Pocket(manacher)

马拉车模板

马拉车求最大回文字串

Codeforces Global Round 7D(马拉车/PAM,回文串)

2018南京ICPCMediocre String Problem 马拉车