Codeforces801B Valued Keys 2017-04-19 00:21 136人阅读 评论(0) 收藏
2 seconds
256 megabytes
standard input
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.
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.
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.
ab
aa
ba
nzwzl
niwel
xiyez
ab
ba
-1
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) 收藏的更多相关文章
- Raspberry Pi + 3个USB摄像头 + Motion(简易监控设备配置记录1——介绍以及安装) 分类: Raspberry Pi 服务器搭建 2015-04-12 19:21 226人阅读 评论(0) 收藏
参考: Debian官网链接 Motion官网链接 首先,参见Debian官网链接对Motion的介绍,网页中包含了所有相关依赖包,请首先确保这些依赖包的安装. Motion介绍 摘出对Motion的 ...
- 菊花加载第三方--MBprogressHUD 分类: ios技术 2015-02-05 19:21 120人阅读 评论(0) 收藏
上次说到了网络请求AFN,那么我们在网络请求的时候,等待期间,为了让用户不认为是卡死或程序出错,一般都会放一个菊花加载,系统有一个菊花加载类叫UIProgressHUD.但是我今天要说的是一个替代它的 ...
- 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 ...
- 搭建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 目录: ...
- 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 ...
- C/C++中const的用法 分类: C/C++ 2015-07-05 00:43 85人阅读 评论(0) 收藏
const是C语言的关键字,经C++进行扩充,变得功能强大,用法复杂.const用于定义一个常变量(只读变量),当const与指针,引用,函数等结合起来使用时,情况会变得复杂的多.下面将从五个方面总结 ...
- 自动化测试工具QTP的使用实例 分类: 软件测试 2015-06-17 00:23 185人阅读 评论(0) 收藏
1. QTP简介 1.1QTP功能与特点 QTP是QuickTest Professional的简称,是一种自动化软件测试工具.在软件的测试过程中,QTP主要来用来通过已有的测试脚本执行重复的手动测试 ...
- 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 ...
- Prime Path 分类: 搜索 POJ 2015-08-09 16:21 4人阅读 评论(0) 收藏
Prime Path Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14091 Accepted: 7959 Descripti ...
随机推荐
- 再识ASCII实体、符号实体和字符实体
一.前言 相信大家都熟悉通过字符实体 来实现多个连续空格的输入吧!本文打算对三类HTML实体及JS相关操作作进一步的整理和小结,若有纰漏请大家指正,谢谢. 二.初识HTML实 ...
- 常用类一一基本数据类型的包装类(WrapperClass)一一Byte Short nteger Long Float Double Character Boolean
为什么需要包装类? JAVA是支持跨平台的.可以在服务器 也可以在手机上运行 基本数据类型 在栈中 效率更高 包装类 将数据类型转换成对象 在 堆中 利于操作 package cn.bjsxt.w ...
- 我在JS上解惑之路1
1.为什么既然存在等号(==)非等号 (!=),又会有全等号(===)非全等号(!==)? *唯一的不同是后者判断时不进行类型转换. 例:var sNum = "66"; var ...
- swift iOS开发初步使用
使用Xcode6-Beta 创建一个swift空的工程,新建一个UIViewController,语言选择swift. 在MainViewController.swift 添加如下代码,声明变量及cl ...
- SQL Server优化50法(转载)
虽然查询速度慢的原因很多,但是如果通过一定的优化,也可以使查询问题得到一定程度的解决. 查询速度慢的原因很多,常见如下几种: 1.没有索引或者没有用到索引(这是查询慢最常见的问题 ...
- [leetcode]236. Lowest Common Ancestor of a Binary Tree 二叉树最低公共父节点
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According ...
- CodeSmith生成SQL Server视图的实体类脚本/对应的生成模板
C#生成sql视图的实体类 using System;using System.Text;using CodeSmith.Engine;using SchemaExplorer;using Syste ...
- ubuntu自动拉黑破解ssh服务的IP
2013年的脚本,今天拿出来备份一下. vim /root/secure_ssh.sh #!/bin/bash cat /var/log/auth.log|awk '/Failed/{print $( ...
- css简单分页
html代码 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <ti ...
- Ubuntu下的网络服务
一.Telnet Telnet是teletype network的缩写,表示远程登录协议和方式,分为Telnet客户端和Telnet服务器程序. Telnet服务虽然也属于客户机/服务器模型的服务,但 ...