CodeForces 709C Letters Cyclic Shift
贪心。
肯定是两个$a$之间的那些字符都$-1$,没有$a$就全部$-1$。如果输入的串全是$a$,那么把最后一个$a$改成$z$。
#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include<set> #include<queue> #include<stack> #include<iostream> using namespace std; typedef long long LL; const double pi=acos(-1.0),eps=1e-6; void File() { freopen("D:\\in.txt","r",stdin); freopen("D:\\out.txt","w",stdout); } template <class T> inline void read(T &x) { char c = getchar(); x = 0;while(!isdigit(c)) c = getchar(); while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); } } const int maxn=100010; char s[maxn]; bool flag; int main() { scanf("%s",s); for(int i=0;s[i];i++) { if(s[i]=='a') { if(flag==0) continue; else break; } s[i]--; flag=1; } if(flag==0) { int len=strlen(s); s[len-1]='z'; } printf("%s\n",s); return 0; }