题目内容: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. UVA - 12230 Crossing Rivers(过河)(期望)

    题意:从A到B需要经过n条河,已知AB间距离D和每条河的长度L以及在该条河上的船速v,求A到B平均情况下需多长时间.陆地行走速度为1,船的位置和朝向均匀随机. 分析: 1.过一条河,最短时间L/v(无 ...

  2. Kubernetes1-K8s的简单介绍(转载)

    一.简介 1.什么是Kubernetes 简称K8s,用8代替8个字符"ubernerte"而成的速写,K8s是一个开源的容器编排平台,它是一个跨主机集群的开源容器调度平台,用于管 ...

  3. 【LeetCode】解数独

    做题之前先复习下[STL中的Tuple容器] 我们知道,在Python中,大家都知道tuple这个概念,是一个只读的元素容器,容器内的元素数据类型可以不同,而在CPP中大部分的容器只能储存相同数据类型 ...

  4. C++编程学习(四)声明/枚举

    一.typedef 声明 typedef 为一个已有的类型取一个新的名字 typedef int num;//feet是int的另一个名字num a;//a是int类型 二.枚举类型 enum col ...

  5. OC Swift混编-Swift.h File not found

    https://www.jianshu.com/p/f860fe1718ca 2016.09.13 11:53* 字数 266 阅读 1935评论 1喜欢 1 今天碰到个神坑,本人项目是OC项目,最近 ...

  6. 使用navicat连接mysql8.0.12版本 出现client does not support。。。解决办法

    navicat版本的问题 出现连接失败的原因:mysql8 之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password ...

  7. 禁用 Bootstrap 模态框(Modal) 点击空白时自动关闭

    在做项目的时候,来了这么一个需求,要求打开模态框后,点击空白的地方不让他自动关闭,只能点击关闭按钮才能关闭. 有了需求,就开始查找资料寻求解决的方法. 我找到的解决方法如下: $('#registCo ...

  8. JSTL与EL表达式(为空判断)

    JSTL与EL表达式(为空判断) 一.循环遍历集合  1.在jsp中引入标准函数声明  <%@ taglib uri="http://java.sun.com/jsp/jstl/cor ...

  9. (简单模拟)P1540 机器翻译

    题解: #include<iostream>#include<cmath>using namespace std; int main(){ int m,n; cin>&g ...

  10. Hibernate(一)——入门

    1. 前言         Hibernate是一个开放源代码的ORM持久化框架,它对JDBC进行了非常轻量级的对象封装,使得Java程序员可以随心所欲的使用对象编程思维来操纵数据库.         ...