【题目链接】: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. 小白学开发(iOS)OC_ 字符串写入文件(2015-08-13)

    // //  main.m //  字符串写入文件 // //  Created by admin on 15/8/13. //  Copyright (c) 2015年 admin. All rig ...

  2. luogu3084 Photo 单调队列优化DP

    题目大意 农夫约翰决定给站在一条线上的N(1 <= N <= 200,000)头奶牛制作一张全家福照片,N头奶牛编号1到N.于是约翰拍摄了M(1 <= M <= 100,000 ...

  3. luogu3119 草鉴定

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

  4. splay树入门(带3个例题)

    splay树入门(带3个例题) 首先声明,本教程的对象是完全没有接触过splay的OIer,大牛请右上角.. PS:若代码有误,请尽快与本人联系,我会尽快改正 首先引入一下splay的概念,他的中文名 ...

  5. SQL2000数据库定期自动备份与修改

    SQL2000数据库定期自动备份与修改 http://www.veryhuo.com 2009-11-19 烈火网 投递稿件 我有话说   在SQL server企业管理器中,可以设置数据库的定期自动 ...

  6. tarjan用法——割点

    今天洛谷疯狂给我推送tarjan的题(它好像发现了我最近学tarjan),我正好做一做试一试(顺便练一练快读和宏定义). 其实找割点的tarjan和算强连通分量的tarjan不一样,找割点的判定条件比 ...

  7. 从map到hash

    https://zybuluo.com/ysner/note/1175387 前言 这两种技巧常用于记录和去重量少而分散的状态. 都体现了映射思想. \(map\) 我一般是数组开不下时拿这玩意判重. ...

  8. 协议-网络-安全协议:SSH(安全外壳协议)

    ylbtech-协议-网络-安全协议:SSH(安全外壳协议) SSH 为 Secure Shell 的缩写,由 IETF 的网络小组(Network Working Group)所制定:SSH 为建立 ...

  9. iOS网络开发工具集----字符串操作和时间操作

    一.字符串的操作方法 #pragma mark - 创建字符串 - (void)CreatString { // <1> 创建字符串 NSString *strS = @"Thi ...

  10. 93.EXTJS Form之VTypes

    转自:http://blog.sina.com.cn/s/blog_7778950d0100y2pg.html 本文我们主要探讨一下EXTJS的Form中验证的问题,可能用过EXTJS的Form的人都 ...