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浙江省赛 Strings in the Pocket【manacher】
Strings in the Pocket 题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=6012 题意 给你两个字符 ...
- 使用strings查看二进制文件中的字符串
使用strings查看二进制文件中的字符串 今天介绍的这个小工具叫做strings,它实现功能很简单,就是找出文件内容中的可打印字符串.所谓可打印字符串的涵义是,它的组成部分都是可打印字符,并且以nu ...
- shell 字符串判断
字符串的判断 '-z 字符串' 判断字符串是否为空(为空返回真) '-n 字符串' 判断字符串是否为非空(非空返回真) '字符串1==字符串2' 判断字符串1是否和字符串2相等(相等返回真) '字符串 ...
- 由一篇吐槽对String空字符串判断的文章所引发的碎碎念
一.起因 最近有篇关于String空字符串判断的文章火了,老是看到这篇文章,既然如此我也只好认真看了下:程序员晒出一段代码引来无数网友狂喷!网友:你就活该当码农! 我也觉得这段代码写的不怎么的,首先程 ...
- JavaScript空字符串判断
JavaScript空字符串判断 本文完整示例代码GIT仓: 测试用例完整代码:isNullOrEmpty jPublic GIT仓:jPublic 比较常见写法 if (str == 'undefi ...
- sh_16_字符串判断方法
sh_16_字符串判断方法 # 1. 判断空白字符 space_str = " \t\n\r" print(space_str.isspace()) # 2. 判断字符串中是否只包 ...
- Shell系列(28)- 条件判断之字符串判断
字符串判断 $变量时要用双引号引起来,即"$变量" 测试选项 作用 -z 字符串 判断字符串是否为空(为空返回真) -n 字符串 判断字符串是否为非空(非空返回真) 字符串1 == ...
- ZOJ 4110 Strings in the Pocket (马拉车+回文串)
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4110 题目: BaoBao has just found two s ...
- ZOJ4110 Strings in the Pocket(2019浙江省赛)
给出两个字符串,询问有多少种反转方法可以使字符串1变成字符串2. 如果两个串相同,就用马拉车算法找回文串的数量~ 如果两个串不同,从前往后找第一个不同的位置l,从后往前找第二个不同的位置r,反转l和r ...
随机推荐
- Linux OOM 自动杀死进程
问题描述: 今天上班后,登录一台内网测试服务器,发现部分进程失踪 (Nginx/PHP-FPM/MySQL/Crond). 解决方法: 1.首先启动这些进程,保证正常提供服务. 2.查看服务器日志信息 ...
- Java服务器工程师任职资格
Java服务器端开发工程师 1.Java服务器端3年以上开发经验 2.至少一个完整游戏项目经验 3.熟练掌握OOA.OOD.OOP 4.掌握常见网游协议开发方法 5.对TCP/IP有深入了解 6.对消 ...
- springmvc jpa
昨天帮同学搭建了一个springmvc+jpa+beetl模板引擎的项目环境,供参考. https://files.cnblogs.com/files/startnow/lntu-demo.zip 数 ...
- sha1sum校验下载的文件
[root@mhc1 test]# sha1sum Percona-XtraBackup-2.4.8-r97330f7-jessie-x86_64-bundle.tara9c6b1c7cb3bf98b ...
- Level Of Detail
[Level Of Detail] LOD0离摄像机最近,LODN离摄像机最远.LOD Group组件的用法是,将此组件挂在根节点上,然后每一个LOD挂同样多的Renderer(通常是子对象). At ...
- strncmp memcmp区别
内部实现:前者逐每个字符进行比较,并判当前字符是否为0: 后者逐内存块进行比较. 效率:后者自然要优,不论从内部实现上,还是系统优化上. 场景:后者无法替代前者.在项目中遇到一种情况,两个字符串比较, ...
- 【SPOJ - LCS2】Longest Common Substring II【SAM】
题意 求出多个串的最长公共子串. 分析 刚学SAM想做这个题的话最好先去做一下那道codevs3160.求两个串的LCS应该怎么求?把一个串s1建自动机,然后跑另一个串s2,然后找出s2每个前缀的最长 ...
- const&static&extern
const 结论: 如果const写在指针变量名的旁边, 那么指针的指向不能变, 而指向的内存空间的值可以变 如果const写在数据类型的左边或者右边, 那么指针的指向可以改变, 但是指向的内存空间的 ...
- spring mabatis springmvc 看过
.Spring中AOP的应用场景.Aop原理.好处? 答:AOP--Aspect Oriented Programming面向切面编程:用来封装横切关注点,具体可以在下面的场景中使用: Authent ...
- jQuery中deferred对象的使用(一)
在jquery1.5之后的版本中,加入了一个deferred对象,也就是延迟对象,用来处理未来某一时间点发生的回调函数.同时,还改写了ajax方法,现在的ajax方法返回的是一个deferred对象. ...