CF-Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)-B-Valued Keys

来源:互联网 发布:wish产品怎么优化 编辑:程序博客网 时间:2024/06/01 09:40

ACM模版

描述

描述

题解

十分简单的一道水题,看懂题就能秒,不用多一丝一毫的犹豫。

这是一个特判问题,已知f(x, y) = min(x, y) = z,这里给定两个字符串xz,求yy的结果不唯一,其实,除去-1的情况,直接让y = z输出也是没问题的,说到-1的情况,当出现z的值比x还小时,就直接 GG。

代码

#include <iostream>#include <string>using namespace std;int main(int argc, const char * argv[]){    string s1, s2;    while (cin >> s1 >> s2)    {        string res = s2;        int flag = 0;        for (int i = 0; i < s1.length(); i++)        {            if (res[i] > s1[i])            {                flag = 1;                break;            }        }        if (flag)        {            cout << "-1\n";            continue;        }        cout << res << '\n';    }    return 0;}
0 0
原创粉丝点击