Test instructions: Given two strings of the same length, let you find a string, the dictionary order between the two.
Analysis: The problem at that time WA many times, and later found that it is so water, we just add the S string, and then the same as the arithmetic, the carry carry, and then compared to T-line.
The code is as follows:
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <set > #include <cstring> #include <cmath> #include <map> #include <cctype>using namespace std; const int MAXN = 5;string s, t;int main () {while (CIN >> s >> t) { int n = s.size (); int cnt = 0; ++S[N-1]; if (s[n-1] > ' z ') {s[n-1] = ' a '; CNT = 1; } for (int i = n-2; I >= 0; i.) { s[i] + = CNT; if (s[i] > ' z ') {s[i] = ' a '; CNT = 1; } Else cnt = 0; } if (s = = t) puts ("No such string"); Else cout << s << endl; } return 0;}
Codeforces 518A Vitaly and Strings (water problem, string)