题目: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(马拉车+字符串判断)的更多相关文章

  1. 2019浙江省赛 Strings in the Pocket【manacher】

    Strings in the Pocket 题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=6012 题意 给你两个字符 ...

  2. 使用strings查看二进制文件中的字符串

    使用strings查看二进制文件中的字符串 今天介绍的这个小工具叫做strings,它实现功能很简单,就是找出文件内容中的可打印字符串.所谓可打印字符串的涵义是,它的组成部分都是可打印字符,并且以nu ...

  3. shell 字符串判断

    字符串的判断 '-z 字符串' 判断字符串是否为空(为空返回真) '-n 字符串' 判断字符串是否为非空(非空返回真) '字符串1==字符串2' 判断字符串1是否和字符串2相等(相等返回真) '字符串 ...

  4. 由一篇吐槽对String空字符串判断的文章所引发的碎碎念

    一.起因 最近有篇关于String空字符串判断的文章火了,老是看到这篇文章,既然如此我也只好认真看了下:程序员晒出一段代码引来无数网友狂喷!网友:你就活该当码农! 我也觉得这段代码写的不怎么的,首先程 ...

  5. JavaScript空字符串判断

    JavaScript空字符串判断 本文完整示例代码GIT仓: 测试用例完整代码:isNullOrEmpty jPublic GIT仓:jPublic 比较常见写法 if (str == 'undefi ...

  6. sh_16_字符串判断方法

    sh_16_字符串判断方法 # 1. 判断空白字符 space_str = " \t\n\r" print(space_str.isspace()) # 2. 判断字符串中是否只包 ...

  7. Shell系列(28)- 条件判断之字符串判断

    字符串判断 $变量时要用双引号引起来,即"$变量" 测试选项 作用 -z 字符串 判断字符串是否为空(为空返回真) -n 字符串 判断字符串是否为非空(非空返回真) 字符串1 == ...

  8. ZOJ 4110 Strings in the Pocket (马拉车+回文串)

    链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4110 题目: BaoBao has just found two s ...

  9. ZOJ4110 Strings in the Pocket(2019浙江省赛)

    给出两个字符串,询问有多少种反转方法可以使字符串1变成字符串2. 如果两个串相同,就用马拉车算法找回文串的数量~ 如果两个串不同,从前往后找第一个不同的位置l,从后往前找第二个不同的位置r,反转l和r ...

随机推荐

  1. Django 使用体会

    最近急于赶项目,少有更新博文.如今项目大致不那么赶了,终于可以在晚上码字码文章,而不是码代码了. 从开始使用Django开发到现在, 也已经有大半年了.公司的项目也是逐步地加功能,加模块,一步步完善设 ...

  2. Agile1001社区10月份活动:一张图解读企业级产品思维

    活动信息 主题:一张图解读企业级产品思维 地点:北京市海淀区苏州街3号大恒科技大厦南座4层 时间: 2017-10-15 14:00 - 17:00 报名链接:http://www.hdb.com/p ...

  3. beego 中文教程

    https://www.kancloud.cn/hello123/beego/126087

  4. linux shell脚本编程笔记(一): 构建基本脚本

    1. echo -n str        打印不换行 2. 反引号来圈住命令传入变量 eg: 生成日志文件: #!/bin/bash today=`date +%y%m%d` ls /usr/bin ...

  5. js使用浏览器的另存为下载文件

    页面上的页面如下: 我需要根据返回的url下载文件: js: //判断浏览器类型 function myBrowser(){ var userAgent = navigator.userAgent; ...

  6. HRESULT:0x80070057 (E_INVALIDARG)

    笔记本蓝屏后,在vs2010中调试项目时出现该异常, 解决方法:清空C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Fi ...

  7. Linux系统profile、bashrc、bash_profile等环境设置文件的使用

    一.前言 关于bash的环境设置文件,分为系统设置和个人设置,一般来说建议用户直接修改个人的设置. 本文测试环境为:centos6.5. 二.系统设置值 1. /etc/sysconfig/i18n ...

  8. udacity term_sim.x86_64 ubuntu16.04 Vmware

    打印信息 ./term2_sim.x86_64 Set current directory to /home/mwolfram/udacity/sdcnd/term2/term2_sim_linux ...

  9. 软件测试流程(Test Flow)

    Bug Status Definition Bug Management Process Outline Bug Severity&Priority Criteria Definition

  10. code1074 食物链

    开3*n的并查集,其中x用来连接与x同类的,x+n用来连接x吃的,x+2*n用来连接x被吃的. 1 x y时,如果 x吃y 或 x被y吃,那么为假话, 否则x与y同类,x吃的y也吃,x被吃的y也被吃: ...