C. Letters Cyclic Shift
time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.

What is the lexicographically minimum string that can be obtained from s by performing this shift exactly once?

Input

The only line of the input contains the string s (1 ≤ |s| ≤ 100 000) consisting of lowercase English letters.

Output

Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring.

Examples
Input
codeforces
Output
bncdenqbdr
Input
abacaba
Output
aaacaba
Note

String s is lexicographically smaller than some other string t of the same length if there exists some 1 ≤ i ≤ |s|, such that s1 = t1, s2 = t2, ..., si - 1 = ti - 1, and si < ti.

题目连接:http://codeforces.com/contest/709/problem/C


题意:将s的子串进行一次变换,输出字典序最小的s。

思路:水题。注意一定要进行一次变换。

代码:

 #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
string s;
char ans[];
int main()
{
int i;
cin>>s;
char ch;
int sign=,flag=;
for(i=; i<s.size(); i++)
{
if(s[i]->='a') ch=s[i]-;
else ch='z';
if(sign==&&ch<=s[i]) ans[i]=ch,flag=;
else if(flag==) ans[i]=s[i];
else ans[i]=s[i],sign=;
}
if(flag==) ans[i-]=ch;
for(i=; i<s.size(); i++)
printf("%c",ans[i]);
cout<<endl;
return ;
}

Codeforces 709C 模拟的更多相关文章

  1. CodeForces - 427B (模拟题)

    Prison Transfer Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Sub ...

  2. CodeForces - 404B(模拟题)

    Marathon Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Sta ...

  3. Codeforces 709B 模拟

    B. Checkpoints time limit per test:1 second memory limit per test:256 megabytes input:standard input ...

  4. CodeForces - 404A(模拟题)

    Valera and X Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit ...

  5. Codeforces 390A( 模拟题)

    Inna and Alarm Clock Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64 ...

  6. Codeforces 452D [模拟][贪心]

    题意: 给你k件衣服处理,告诉你洗衣机烘干机折叠机的数量,和它们处理一件衣服的时间,要求一件衣服在洗完之后必须立刻烘干,烘干之后必须立刻折叠,问所需的最小时间. 思路: 1.按照时间模拟 2.若洗完的 ...

  7. CodeForces - 796B 模拟

    思路:模拟移动即可,如果球落入洞中停止移动.注意:有可能第一个位置就是洞!! AC代码 #include <cstdio> #include <cmath> #include ...

  8. CodeForces - 864C-Bus-(模拟加油站问题)

    https://vjudge.net/problem/CodeForces-864C 题意:两地之间有个加油站,往返走k个单程,最少加油多少次. 大佬几十行代码就解决,我却要用一百多行的if语句模拟解 ...

  9. 【题解】Berland.Taxi Codeforces 883L 模拟 线段树 堆

    Prelude 题目传送门:ヾ(•ω•`)o Solution 按照题意模拟即可. 维护一个优先队列,里面装的是正在运营中的出租车,关键字是乘客的下车时间. 维护一个线段树,第\(i\)个位置表示第\ ...

随机推荐

  1. ie6 双边距问题

    div 设置float和margin margin在float方向上会变成设置值的两倍 解决方法,加上css _display:inline

  2. python 之路06day

    一   字符编码 1   字符编码的定义: 计算机要想工作必须通电,即用‘电’驱使计算机干活,也就是说‘电’的特性决定了计算机的特性.电的特性即高低电平(人类从逻辑上将二进制数1对应高电平,二进制数0 ...

  3. Selenium如何定位动态id的元素?

    怎么定位这类型的元素呢? 根据其他属性定位如果有其他固定属性,最先考虑的当然是根据元素的其他属性来定位,定位方式那么多,何必在这一棵树上吊死.. 根据相对关系定位根据其附近的父节点.子节点.兄弟节点定 ...

  4. [Delphi] 快速获取文件大小

    function GetFileSize(const fName: AnsiString): Int64; var hFile: THandle; begin hFile := _lopen(PAns ...

  5. zabbix监控windows用户登陆情况

    https://yq.aliyun.com/articles/511381 添加登录失败监控项: 特别注意:把类型设置为:文本格式,否则会报类型错误. eventlog[Security,," ...

  6. 使用JSP页面生成PDF报表

    转自:http://developer.51cto.com/art/200907/134261.htm 1.iText简介 iText是一个开放源码的Java类库,可以用来方便地生成PDF文件.大家通 ...

  7. GET和POST的真正区别

    文章来源: http://www.nowamagic.net/librarys/veda/detail/1919 如果有人问你,GET和POST,有什么区别?你会如何回答? 我的经历 前几天有人问我这 ...

  8. mysql查看进程

    select * from information_schema.processlist 查询所有连接到数据库的进程信息.

  9. Qt-状态机

    //以下示例是QT示例中的appchooser例子,使用状态机来进行图标的交互. #include <QtCore> #include <QtWidgets> class Pi ...

  10. v​n​c​服​务​​安​装​与配置

    一.Redhat上VNC Server配置 本文以当前Linux系统未安装VNC服务器为基本,如果已安装请跳过第1节! 前提: 1.安装 TigerVNC Server # yum search ti ...