Mihahim has a string s. He wants to delete exactly one character from it so that the resulting string would be a palindrome. Determine if he can do it, and if he can, what character should be deleted.

Input

The input contains a string s of length (2 ≤ |s| ≤ 200000), consisting of lowercase Latin letters.

Output

If the solution exists, output «YES» (without quotes) in the first line. Then in the second line output a single integer x — the number of the character that should be removed from s so that the resulting string would be a palindrome. The characters in the string are numbered from 1. If there are several possible solutions, output any of them.

If the solution doesn't exist, output «NO» (without quotes).

Examples
input
evertree
output
YES
2
input
emerald
output
NO
input
aa
output
YES
2

从左右两边往中间移动,如果相同,l++,r--,如果不同,第一次循环i==0时,则让l++,第二次循环则让r--,最后判断不同的出现了几次。如果dif是0,l>=r代表本身就是回文,则去掉l位置的字符。

#include <cstring>
#include <cstdio>
#define N 100005
char s[N<<];
int len,l,r,dif,at;
int main() {
scanf("%s",s);
len=strlen(s);
for(int i=;i<;i++){
dif=;
l=,r=len-;
while(l<r){
if(s[l]!=s[r]){
dif++;
if(i){
at=r;
r--;
}else {
at=l;
l++;
}
}
if(s[l]==s[r]){
l++;
r--;
}
}
if(l>=r&&dif==)at=l;
if(dif<){
printf("YES\n%d\n",at+);
break;
}
}
if(dif>)puts("NO");
}

  

【Gym 100971K】Palindromization的更多相关文章

  1. 【 Gym 101116K 】Mixing Bowls(dfs)

    BUPT2017 wintertraining(15) #4H Gym - 101116K 题意 给定一个菜谱,大写的单词代表混合物,小写的代表基础原料.每个混合物由其它混合物或基础原料组成,不会间接 ...

  2. 【 Gym - 101124E 】Dance Party (数学)

    BUPT2017 wintertraining(15) #4G Gym - 101124 E.Dance Party 题意 有c种颜色,每个颜色最多分配给两个人,有M个男士,F个女士,求至少一对男士同 ...

  3. 【Gym - 101124A】The Baguette Master (数学,几何)

    BUPT2017 wintertraining(15) #4F Gym - 101124A 题意 给定画框宽度,画的四边和一个对角线长度,求画框外沿周长. 题解 过顶点做画框的垂线,每个角都得到两个全 ...

  4. 【 Gym - 101138K 】 The World of Trains (DP)

    BUPT2017 wintertraining(15) #4E Gym - 101138K 题意 N节车厢的火车,每节车厢容量是1~K,那么有\(K^N\)种火车. 求选择D个连续的且容量相同的车厢的 ...

  5. 【 Gym - 101138J 】Valentina and the Gift Tree(树链剖分)

    BUPT2017 wintertraining(15) 4 D Gym - 101138J 数据 题意 n个节点的一棵树,每个节点的权值为g,q个询问,树上的节点U-V,求U到V的路径的最大子段和. ...

  6. 【 Gym - 101138F 】GukiZ Height (数学)

    BUPT2017 wintertraining(15) #4 C Gym - 101138F 题意 初始高度0,目标值h,第i天目标值会下降i,当前高度会改变a[i%n],求高度不小于目标值的最早的时 ...

  7. 【 Gym - 101138D 】Strange Queries (莫队算法)

    BUPT2017 wintertraining(15) #4B Gym - 101138D 题意 a数组大小为n.(1 ≤ n ≤ 50 000) (1 ≤ q ≤ 50 000)(1 ≤ ai ≤  ...

  8. 【Gym - 101164I】Cubes(dfs,剪枝)

    BUPT2017 wintertraining(15) #4 A - I.Cubes Gym - 101164I 题意 将n拆成最少个立方数相加的形式. 题解 根据n的范围,立方数最大不超过400的立 ...

  9. 【GYM 102059】2018-2019 XIX Open Cup, Grand Prix of Korea

    vp了一场gym,我又开心地划水了. A. Coloring Roads 题意:给定一棵树,树边一开始都是无色的,每次操作可以把一个点到根的路径染成某个颜色,每次询问当前树上出现过某个次数的颜色种数. ...

随机推荐

  1. MysqlHelper 需要重写

    using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Text;u ...

  2. http协议(五)web服务器

    1.http1.1规范允许一台http服务器搭建多个web站点... 比如提供web托管服务的供应商,可以用一台服务器为多为客户服务,也可以以每位客户持有的域名运行各自不同的网站,这里利用了虚拟服务器 ...

  3. memcache分布式 [一致性hash算法] 的php实现

    最近在看一些分布式方面的文章,所以就用php实现一致性hash来练练手,以前一般用的是最原始的hash取模做分布式,当生产过程中添加或删除一台memcache都会造成数据的全部失效,一致性hash就是 ...

  4. 关于a标签和submit标签

    a如果没有连接“#”:“javascript:void(0)”;或“(胡乱写一堆)” 这两个标签点击都有刷新功能,所以会清空你的数据.

  5. IE下默认TD colspan rowspan值为1

    IE下默认TD colspan rowspan值为1,即使这个TD没有合并没有rowspan,colspan属性,其值都为1,chrome下正常. 判断是否rowspan colspan为TD.get ...

  6. C#中使用Log4net日志输出到本地文件、Textbox或Listview

    网上很多配置log4net的方法,但是排行靠前的 根本就没有说明清除,导致浪费了两个小时来搞清楚如何配置,真是无语,特写此文,给那些刚接触log4net的朋友 1.参考链接:http://blog.s ...

  7. TinyFrame升级之九:实现复杂的查询

    本章我们主要讲解如何实现一个复杂的查询.由于目前TinyFrame框架已经投入到了实际的项目生产中,所以我很乐意将项目中遇到的任何问题做以记录并备忘. 这章中,我们提到的查询界面如下所示: 其中,涉及 ...

  8. 安装mint的时候提示:Not compatible with your operating system or architecture: fsevents@1.0.11

    Since fsevents is an API in OS X allows applications to register for notifications of changes to a g ...

  9. HTTP真的很简单

    原文:HTTP Made Really Easy因为我本身网络基础就很差,所以看到这篇文章一方面是学习网络知识,另一方面为了锻炼我蹩脚的英语水平,文中如有错误,欢迎浏览指正! 前言 在看这篇文章的时候 ...

  10. Jquery 页面首次加载方式

    $(document).ready(function(){ alert("111"); }); $(function(){ alert("222"); }); ...