感觉简单,没过TT
#include <iostream> #include<math.h> #include<string.h> #include<vector> #include<algorithm> using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(void) { string s; cin>>s; int j='a'; for(size_t i=0;i<s.size();i++) { if(s[i]==j&&j<='z') { j++; } else if(s[i]+1==j&&j<='z') { s[i]+=1; j++; } else { ; } } if(j>'z') { cout<<s; } else { cout<<"-1"; } return 0; }