B. Valued Keys
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

You found a mysterious function f. The function takes two strings s1 and s2.
These strings must consist only of lowercase English letters, and must be the same length.

The output of the function f is another string of the same length. The i-th
character of the output is equal to the minimum of the i-th character of s1 and
the i-th character of s2.

For example, f("ab", "ba") =
"aa", and f("nzwzl",
"zizez") = "niwel".

You found two strings x and y of
the same length and consisting of only lowercase English letters. Find any string z such that f(x, z) = y,
or print -1 if no such string z exists.

Input

The first line of input contains the string x.

The second line of input contains the string y.

Both x and y consist
only of lowercase English letters, x and y have
same length and this length is between 1 and 100.

Output

If there is no string z such that f(x, z) = y,
print -1.

Otherwise, print a string z such that f(x, z) = y.
If there are multiple possible answers, print any of them. The string z should be the same length as x and y and
consist only of lowercase English letters.

Examples
input
ab
aa
output
ba
input
nzwzl
niwel
output
xiyez
input
ab
ba
output
-1
Note

The first case is from the statement.

Another solution for the second case is "zizez"

There is no solution for the third case. That is, there is no z such that f("ab", z) =  "ba".

————————————————————————————————————

题目给出一种字符串组合方法,把两个等长字符串按位取小,现在给出其中一个串和终串,求另一个串

思路:终串每一位一定小于等于给出串,不符合输出-1,否则输出终串;

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue> using namespace std; int main()
{
char s1[105],s2[105];
while(~scanf("%s%s",s1,s2))
{
int k=strlen(s1);
int flag=0;
for(int i=0;i<k;i++)
{
if(s1[i]<s2[i])
{
flag=1;
break;
}
}
if(flag)
printf("-1\n");
else
printf("%s\n",s2); }
return 0;
}

Codeforces801B Valued Keys 2017-04-19 00:21 136人阅读 评论(0) 收藏的更多相关文章

  1. Raspberry Pi + 3个USB摄像头 + Motion(简易监控设备配置记录1——介绍以及安装) 分类: Raspberry Pi 服务器搭建 2015-04-12 19:21 226人阅读 评论(0) 收藏

    参考: Debian官网链接 Motion官网链接 首先,参见Debian官网链接对Motion的介绍,网页中包含了所有相关依赖包,请首先确保这些依赖包的安装. Motion介绍 摘出对Motion的 ...

  2. 菊花加载第三方--MBprogressHUD 分类: ios技术 2015-02-05 19:21 120人阅读 评论(0) 收藏

    上次说到了网络请求AFN,那么我们在网络请求的时候,等待期间,为了让用户不认为是卡死或程序出错,一般都会放一个菊花加载,系统有一个菊花加载类叫UIProgressHUD.但是我今天要说的是一个替代它的 ...

  3. ZOJ2201 No Brainer 2017-04-16 19:21 54人阅读 评论(0) 收藏

    No Brainer Time Limit: 2 Seconds      Memory Limit: 65536 KB Zombies love to eat brains. Yum. Input ...

  4. 搭建hadoop2.6.0集群环境 分类: A1_HADOOP 2015-04-20 07:21 459人阅读 评论(0) 收藏

    一.规划 (一)硬件资源 10.171.29.191 master 10.171.94.155  slave1 10.251.0.197 slave3 (二)基本资料 用户:  jediael 目录: ...

  5. How to create your own custom 404 error page and handle redirect in SharePoint 分类: Sharepoint 2015-07-08 00:22 4人阅读 评论(0) 收藏

    1. In your MOSS server, make a copy of %systemdrive%\Program Files\Common Files\Microsoft Shared\Web ...

  6. C/C++中const的用法 分类: C/C++ 2015-07-05 00:43 85人阅读 评论(0) 收藏

    const是C语言的关键字,经C++进行扩充,变得功能强大,用法复杂.const用于定义一个常变量(只读变量),当const与指针,引用,函数等结合起来使用时,情况会变得复杂的多.下面将从五个方面总结 ...

  7. 自动化测试工具QTP的使用实例 分类: 软件测试 2015-06-17 00:23 185人阅读 评论(0) 收藏

    1. QTP简介 1.1QTP功能与特点 QTP是QuickTest Professional的简称,是一种自动化软件测试工具.在软件的测试过程中,QTP主要来用来通过已有的测试脚本执行重复的手动测试 ...

  8. hdu 1047 (big integer sum, fgets or scanf, make you func return useful infos) 分类: hdoj 2015-06-18 08:21 39人阅读 评论(0) 收藏

    errors made, boundary conditions, <= vs < , decreasing vs increasing , ++, –, '0'/'1' vs 0/1 p ...

  9. Prime Path 分类: 搜索 POJ 2015-08-09 16:21 4人阅读 评论(0) 收藏

    Prime Path Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14091 Accepted: 7959 Descripti ...

随机推荐

  1. Haskell语言学习笔记(47)Arrow(2)

    Function, Monad, Arrow f :: Int -> (Int, Int) f = \x -> let y = 2 * x z1 = y + 3 z2 = y - 5 in ...

  2. Delphi编程实现是否开启“平滑屏幕字体边缘“

    在Windows高级设置中的视觉效果中可以设置是否开启“平滑屏幕字休边缘”,可以通过编程的方式来实现: if SystemParametersInfo(SPI_SETFONTSMOOTHING, 1, ...

  3. 关于struts.xml配置文件的说明

    <struts> <!-- action: 对应controller 中的类的 name: 匹配url要访问的类 class:包名+类名 通过反射产生对象 method:指定默认访问 ...

  4. hibernate中.常见的hql查询语句

    hql是非常有意识的被设计为完全面向对象的查询 基本规则: 1.hql语法类似于sql,但它后面跟的不是表名和字段名,而是类名和属性名 2.hql大小写不敏感.但是设计java类名,包名,属性名时大小 ...

  5. sql语句执行的时间

    统计mysql里每条SQL语句执行的时间 收藏 CrazyHarry 发表于 2年前 阅读 3785 收藏 8 点赞 3 评论 3 Google.Github 双重认证前端课程,独家硅谷内容,每周直播 ...

  6. Mysql一些记忆

    mysql修改密码报错是yum 安装mysql5.7 是 出现无法登陆问题以及mysql error You must reset your password using ALTER USER sta ...

  7. t检验,T Test (Student’s T-Test)

    1.什么是T test? t-test:比较数据的均值,告诉你这两者之间是否相同,并给出这种不同的显著性(即是否是因为偶然导致的不同) The t test (also called Student’ ...

  8. 使用JS伪造Post请求

    [使用JS伪造Post请求] 提到伪造Post请求,首先想到的是构造HTTP包.但实际上有一种更简单的方法,构造HTML FORM表单,使用js进行提交.如下:

  9. 早停法(Early Stopping)

    一.早停法简介(Early Stopping)当我们训练深度学习神经网络的时候通常希望能获得最好的泛化性能(generalization performance,即可以很好地拟合数据).但是所有的标准 ...

  10. Intellij IDEA 热部署处理

     1. 首先参考IDEA热部署同行经验分享:  Intellij IDEA 4种配置热部署的方法 2. IDEA 热部署实战: springboot项目: 不要引入热部署工具包spring-boot- ...