Codeforces Round #410 (Div. 2) A
Description
Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome.
A palindrome is a string that reads the same backward as forward, for example strings "z", "aaa", "aba", "abccba" are palindromes, but strings "codeforces", "reality", "ab" are not.
The first and single line contains string s (1 ≤ |s| ≤ 15).
Print "YES" (without quotes) if Mike can change exactly one character so that the resulting string is palindrome or "NO" (without quotes) otherwise.
abccaa
YES
abbcca
NO
abcda
YES
题意:必须修改一次字符串中的字符,问能不能成为回文串
解法:模拟,注意必须要修改字符
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=;
string s,ss,sss,ssss,s1;
int main()
{
cin>>s;
for(int i=;i<s.size();i++)
{
ss=s;
for(int j=;j<;j++)
{
ss[i]='a'+j;
if(s[i]==ss[i]) continue;
sss=ss;
ssss=ss;
reverse(sss.begin(),sss.end());
if(ssss==sss)
{
cout<<"YES";
return ;
} }
}
cout<<"NO"<<endl;
return ;
}
Codeforces Round #410 (Div. 2) A的更多相关文章
- Codeforces Round #410 (Div. 2)
Codeforces Round #410 (Div. 2) A B略..A没判本来就是回文WA了一次gg C.Mike and gcd problem 题意:一个序列每次可以把\(a_i, a_{i ...
- Codeforces Round #410 (Div. 2)C. Mike and gcd problem
题目连接:http://codeforces.com/contest/798/problem/C C. Mike and gcd problem time limit per test 2 secon ...
- Codeforces Round #410 (Div. 2)(A,字符串,水坑,B,暴力枚举,C,思维题,D,区间贪心)
A. Mike and palindrome time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...
- Codeforces Round #410 (Div. 2)A B C D 暴力 暴力 思路 姿势/随机
A. Mike and palindrome time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- Codeforces Round #410 (Div. 2) A. Mike and palindrome
A. Mike and palindrome time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- Codeforces Round #410 (Div. 2) A. Mike and palindrome【判断能否只修改一个字符使其变成回文串】
A. Mike and palindrome time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- Codeforces Round #410 (Div. 2)D题
D. Mike and distribution time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- Codeforces Round #410 (Div. 2)C题
C. Mike and gcd problem time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces Round #410 (Div. 2) B
B. Mike and strings time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
随机推荐
- linux 输入子系统(3) button platform driver
button platform driver 一般位于driver/input/keyboard/gpio_keys.c /*用于按键事件的上报,它将在按键的中断发生后被调用.其中逻辑就是获取到按键类 ...
- 《从零開始学Swift》学习笔记(Day 61)——Core Foundation框架之内存管理
原创文章,欢迎转载. 转载请注明:关东升的博客 在Swift原生数据类型.Foundation框架数据类型和Core Foundation框架数据类型之间转换过程中,尽管是大部分是能够零开销桥接,零开 ...
- MongoDB经常使用命令
首先我们先安装这个数据库.你能够使用windows或者linux,但推荐使用的是linux,我使用的是ubuntu12.04.在下方的网址中共能够下载,基本都是64位的系统. 假设位linux系统也能 ...
- 设计模式学习笔记——State状态模式
从一个类中,将有关状态的处理分离出来,独立成类,并面向接口编程.作用是可以简化代码,避免过多的条件判断:if-else-
- Erlang Garbage Collector
Erlang Garbage Collector | Erlang Solution blog https://www.erlang-solutions.com/blog/erlang-garbage ...
- jQuery 怎么获取对象
1.JQuery的核心的一些方法 each(callback) '就像循环 $("Element").length; ‘元素的个数,是个属性 $("Element&quo ...
- pod导入第三方库头文件不能自动联想的解决方法
使用了一段时间CocoaPods来管理Objective-c的类库,方便了不少.但是有一个小问题,当我在xcode输入import关键字的时候,没有自动联想补齐代码的功能,需要手工敲全了文件名,难以适 ...
- noi2014魔法森林
为了得到书法大家的真传,小 E 同学下定决心去拜访住在魔法森林中的隐 士.魔法森林可以被看成一个包含
- js判断字符串是否包含某个字符串
String对象的方法 1,indexOf() (推荐) 方法可返回某个指定的字符串值在字符串中首次出现的位置.如果要检索的字符串值没有出现,则该方法返回 -1 var str = "123 ...
- stl里面的空间适配器
一般而言,如果频繁地向system heap申请和释放空间很小的内存空间块(小于128B的),就会对系统内存资源产生很多内存碎片(fragment)的问题,而C++的::operator new() ...