题目内容: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. Elasticsearch 使用集群

    章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...

  2. vue路由 视图命名

    <body> <div id="app"> <p @click="go">hello app!</p> < ...

  3. POJ2002 &&HDU5365 判断给定的点中有多少个不同的正方形

    Squares Time Limit: 3500MS   Memory Limit: 65536K Total Submissions: 17740   Accepted: 6776 Descript ...

  4. cf 755D. PolandBall and Polygon

    题意:把一个多边形往里面连对角线,然后问每次添加多边形被划分为几个部分 产生的部分就是新加对角线与原有对角线相交条数+1,用线段树(大雾)维护一下. #include<bits/stdc++.h ...

  5. 对于AVL树和红黑树的理解

    AVL又称(严格)高度平衡的二叉搜索树,也叫二叉查找树.平衡二叉树.window对进程地址空间的管理用到了AVL树. 红黑树是非严格平衡二叉树,统计性能要好于平衡二叉树.广泛的在C++的STL中,ma ...

  6. 吴裕雄--天生自然C++语言学习笔记:C++ 注释

    程序的注释是解释性语句,可以在 C++ 代码中包含注释,这将提高源代码的可读性.所有的编程语言都允许某种形式的注释. C++ 支持单行注释和多行注释.注释中的所有字符会被 C++ 编译器忽略. C++ ...

  7. 2020PHP面试-SQL篇

    一.乐观锁和悲观锁 1.悲观锁是指假设并发更新会发生冲突,不管冲突是否会发生,都会使用锁机制. 优点: 完全保证数据安全. 缺点:锁机制会有额外开销,并发度降低. 可能会产生死锁. 2. 乐观锁是指假 ...

  8. Django回顾之_03_Model属性及后端配置

    1. Django ORM O(objects):类和对象. R(Relation):关系,关系数据库中的表格. M(Mapping):映射. Django ORM框架的功能: a) 建立模型类和表之 ...

  9. PAT 2014 秋

    A 1084 Broken Keyboard 注意大小写即可. #include <cstdio> #include <iostream> #include <algor ...

  10. PyMySQL学习笔记

    一些常用函数及解释 db = pymysql.connect('host','user','password','database') # 连接数据库 cursor = db.cursor() # 创 ...