【题目链接】:http://codeforces.com/contest/798/problem/A

【题意】



让你严格改变一个字符,使得改变后的字符串为一个回文串;

让你输出可不可能;

【题解】



直接无脑暴力改就好;

或者按照回文串的规则;

如果a[i]和a[n-i+1]不同则cnt++

然后看看最后cnt是不是恰好为1,或者为0然后字符串长度为奇数(那样中间那个字符可以任意改)



【Number Of WA】



0



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 110; string s;
int len; bool ok(int l,int r)
{
if (l>=r) return true;
if (s[l]==s[r])
return ok(l+1,r-1);
else
return false;
} int main()
{
//freopen("F:\\rush.txt","r",stdin);
ios::sync_with_stdio(false),cin.tie(0);//scanf,puts,printf�ͱ�����!
cin >> s;
len = s.size();
rep1(i,0,len-1)
{
char t = s[i];
for (char key = 'a';key<='z';key++)
if (key!=t)
{
s[i]=key;
if (ok(0,len-1))
return cout <<"YES"<<endl,0;
}
s[i] = t;
}
cout <<"NO"<<endl;
return 0;
}

【codeforces 798A】Mike and palindrome的更多相关文章

  1. 【codeforces 798B】Mike and strings

    [题目链接]:http://codeforces.com/contest/798/problem/B [题意] 给你n个字符串; 每次操作,你可以把字符串的每个元素整体左移(最左边那个字符跑到最后面去 ...

  2. 【codeforces 798C】Mike and gcd problem

    [题目链接]:http://codeforces.com/contest/798/problem/C [题意] 给你n个数字; 要求你进行若干次操作; 每次操作对第i和第i+1个位置的数字进行; 将 ...

  3. 【codeforces 798D】Mike and distribution

    [题目链接]:http://codeforces.com/contest/798/problem/D [题意] 让你选一个下标集合 p1,p2,p3..pk 使得2*(a[p1]+a[p2]+..+a ...

  4. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  5. 【19.77%】【codeforces 570D】Tree Requests

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. 【34.88%】【codeforces 569C】Primes or Palindromes?

    time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  7. 【25.64%】【codeforces 570E】Pig and Palindromes

    time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  8. 【44.19%】【codeforces 608D】Zuma

    time limit per test2 seconds memory limit per test512 megabytes inputstandard input outputstandard o ...

  9. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

随机推荐

  1. jquery文件批量上传控件Uploadify3.2(java springMVC)

    人比較懒  有用为主 不怎么排版了 先放上Uploadify的官网链接:http://www.uploadify.com/  -->里面能够看到PHP的演示样例,属性说明,以及控件下载地址.分f ...

  2. luogu3119 草鉴定

    题目大意 给出一个有向图,问将图中的哪一个边翻转,会使节点1所在的强连通分量内的节点数最多.输出这个节点数. 题解 让我们看看暴力怎么做,即枚举每一条边,将其翻转,然后求节点1所在强连通分量节点数,然 ...

  3. oc65--协议应用1,接口.做数据类型限定

    // WifeCondition.h #import <Foundation/Foundation.h> @protocol WifeCondition <NSObject> ...

  4. bzoj4950: [Wf2017]Mission Improbable

    跟着靖靖做题%%%%% 这题一看就觉得和之前的某场模拟赛的一道题很像,找假如某行某列的最大值一样的就可以只堆一个,跑匈牙利就行 一开始以为箱子不能移动-_-! 然后有个坑,大家都知道当这个位置有箱子就 ...

  5. Detach a Database

    https://msdn.microsoft.com/en-us/library/ms191491.aspx 方法一:Using SQL Server Management Studio To det ...

  6. POJ 2976(01分数划分+二分)

                                                                                                  Droppi ...

  7. python 10:len(list)(获取列表长度)以及负访问性

    bicycles = ['trek', 'cannondale', 'redline', 'specialized'] print(len(bicycles)) #获取某列表长度,即列表元素个数 pr ...

  8. Hibernate多表映射(三)

    一对多|多对一 一个分类对应多个商品,一个商品只属于一个分类 创建分类表 products用set装,set特点值不能够重复 package com.hibernate.domain; import ...

  9. 重装系统后快速安装.NET 3.5

    每一次重装系统(Windows 8.1 和Windows 10)之后,最让我头疼的一件事就是配置把一大堆软件装上了.通常我会装好SQL Server之后,把电脑放在工作组安装Visual Studio ...

  10. 网上干货 ElasticSearch详解与优化设计

    https://blog.csdn.net/joez/article/details/52171199?locationNum=3&fps=1 分析得很好,需要仔细阅读 问题遗留点: Fiel ...