题目内容:http://codeforces.com/contest/1027/problem/A

题目解析:输入T组字符串,每个字符串都必须改变一次,每个字母改变的规则是变成相邻的字母,字母a只能变b,z只能变y。改变后 的字符依旧是否能够变成回文串,就输出YES,否则就输出NO。注意,相邻的字母并没有固定是左边还右边,所以要考虑分成两种情况,一种本身就是回文串的就输出YES,不是回文串的判断对应位置字符asc码差是否等于2。

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int n,t,flag;
string s;
cin>>t;
while(t--)
{
flag=;
cin>>n>>s;
for(int i=; i<n/; i++)
if(s[i]!=s[n-i-]&&abs(s[i]-s[n-i-])!=)
{//用ascll码理解,满足:既不相等且相差非2
puts("NO");
flag=; break;
}
if(!flag)puts("YES");
}
return ;
}

参考出处:https://blog.csdn.net/memory_qianxiao/article/details/81838111

1027A. Palindromic Twist#变形回文串的更多相关文章

  1. Minimum Palindromic Factorization(最少回文串分割)

    Minimum Palindromic Factorization(最少回文串分割) 以下内容大部分(可以说除了关于回文树的部分)来自论文A Subquadratic Algorithm for Mi ...

  2. [LeetCode] Longest Palindromic Substring 最长回文串

    Given a string S, find the longest palindromic substring in S. You may assume that the maximum lengt ...

  3. Palindromic characteristics CodeForces - 835D (区间DP,预处理回文串问题)

    Palindromic characteristics of string s with length |s| is a sequence of |s|integers, where k-th num ...

  4. 516. Longest Palindromic Subsequence最长的不连续回文串的长度

    [抄题]: Given a string s, find the longest palindromic subsequence's length in s. You may assume that ...

  5. HDU5658:CA Loves Palindromic (回文树,求区间本质不同的回文串数)

    CA loves strings, especially loves the palindrome strings. One day he gets a string, he wants to kno ...

  6. LightOJ - 1205:Palindromic Numbers (数位DP&回文串)

    A palindromic number or numeral palindrome is a 'symmetrical' number like 16461 that remains the sam ...

  7. 《LeetBook》leetcode题解(5):Longest Palindromic [M]——回文串判断

    我现在在做一个叫<leetbook>的免费开源书项目,力求提供最易懂的中文思路,目前把解题思路都同步更新到gitbook上了,需要的同学可以去看看 书的地址:https://hk029.g ...

  8. Leetcode0005--Longest Palindromic Substring 最长回文串

    [转载请注明]http://www.cnblogs.com/igoslly/p/8726771.html 来看一下题目: Given a string s, find the longest pali ...

  9. PAT 甲级 1024 Palindromic Number (25 分)(大数加法,考虑这个数一开始是不是回文串)

    1024 Palindromic Number (25 分)   A number that will be the same when it is written forwards or backw ...

随机推荐

  1. WIN10怎么查看端口,并杀死进程

    在命令行执行一下命令 netstat -ano | findstr "

  2. C语言:大数求和

    点击获取题目 1410: [蓝桥杯]高精度加法 时间限制: 1 Sec  内存限制: 256 MB提交: 28  解决: 20[状态] [提交] [命题人:外部导入] 题目描述 输入两个整数a和b,输 ...

  3. 十七、CI框架之数据库操作insert用法

    一.代码如下: 二.我们访问一下页面 三.查看数据库,已经插入了一条数据 不忘初心,如果您认为这篇文章有价值,认同作者的付出,可以微信二维码打赏任意金额给作者(微信号:382477247)哦,谢谢.

  4. Java中多态的实例

    public class cf { /** * 实际上这里涉及方法调用的优先问题, * 优先级由高到低依次为:this.show(O).super.show(O).this.show((super)O ...

  5. Short Essay你真的会写了吗?

    提到short essay(可能其他essay也一样),很多同学都很头疼.“没有思路?不知从何下笔?没有亮点?”等等,这些都是同学们的致命伤,因此,short essay就成为了广大留学生的“送命题” ...

  6. LeetCode做题笔记之动态规划

    LeetCode之动态规划 时间有限只做了下面这几道:70.338.877.96.120.95.647,后续会继续更新 70:爬楼梯 先来道简单的练练手,一道经典的动态规划题目 可以采用动态规划的备忘 ...

  7. part8 详情页面动态路由以及banner布局

    1.<router-link>标签 a标签就会把里面文字的颜色变掉 那我们可以换一种写法 <router-link tag='li'> //这样vue就会把这个标签渲染成li标 ...

  8. VS2013的工程移植到VS2008

    VS2013的工程完成后,用VS2008创建一个名称一样的工程(大小写也一样). 具体过程参考http://blog.csdn.net/sz76211822/article/details/42775 ...

  9. python安装wordcloud、jieba,pyecharts

    1.安装wordcloud: 适用于无法使用pip install wordcloud安装的情况: 据python和windows 版本 到https://www.lfd.uci.edu/~gohlk ...

  10. OGG实验:喂奶间隔数据表通过OGG配置同步

    我之前在<使用SQL计算宝宝每次吃奶的时间间隔(数据保障篇)>中提到数据实时同步的方案,其中有一种是数据表通过OGG进行同步,当时没有详细展开测试,只给了之前学习OGG时的配置示例.由于之 ...