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 ...
随机推荐
- AutoMapper差异内容备份
公司就得项目用的automapper 是 4.2.1 当时用的方法是:Mapper.CreateMap<source,sourceDto>(); 在最新版 6.0.1 中,这些个方法被删除 ...
- Asp .net core api+Entity Framework core 实现数据CRUD数据库中(附Git地址)
最近在学dotNetCore 所以尝试了一下api 这个功能 不多说了大致实现如下 1.用vs2017建立一个Asp.net Core Web 应用程序 在弹出的对话框中选择 Web API 项目名 ...
- 一条跨库更新数据的sql
UPDATE [db1].[dbo].[R_ResAndBook] SET SectionID=TT2.newsecidFROM [SmartCampus].[dbo].[R_ResAndBo ...
- 在Ajax请求中什么时候用GET方式什么时候用POST方式?
当我们有大量数据要传送时最好的办法是一次发出多个只传递少量信息的Ajax调用时.如果你正用一个Ajax调用发送大量数据,那么最好是结束这种做法,因为这样做并不能节约时间. 因此,需要传送大量数据能成为 ...
- java算法 蓝桥杯 摆花
问题描述 小明的花店新开张,为了吸引顾客,他想在花店的门口摆上一排花,共m盆.通过调查顾客的喜好,小明列出了顾客最喜欢的n种花,从1到n标号.为了在门口展出更多种花,规定第i种花不能超过ai盆,摆花时 ...
- java实现文件的拷贝以及文件的删除
/** * 将文件拷贝到指定目录 * @param oldAddress 文件所在目录(文件的全路径) * @param newAddress 指定目录(包含复制文件的全名称) * @throws E ...
- 快速上手Runtime(四)之动态添加方法
如果一个类方法非常多,加载类到内存的时候也比较耗费资源,可以使用动态给某个类,添加方法解决.做到优化内存,节省资源的效果. // // Person.m // ResolveInstanceMetho ...
- 使用jquery修改表单的提交地址
基本思路: 通过使用jquery选择器得到对应表单的jquery对象,然后使用attr方法修改对应的action 示例程序一: 默认情况下,该表单会提交到page_one.html 点击button之 ...
- C++ split
/*************************************************Function: splitDescription: 根据空格切分字符串Calls: // 被本函 ...
- 最长的相同节点值路径 · Longest Univalue Path
[抄题]: Given a binary tree, find the length of the longest path where each node in the path has the s ...