Codeforces 518A Vitaly and Strings (water problem, string)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.