Codeforces 801B - Valued Keys
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
题目大意:给你字符串x,y,看能不能找到z,使得f(x,z)=y;如果存在,输出任意一个z,如果不存在,输出-1。
方法:思维题,如果x[i]<y[i],那么肯定不存在,输出-1。
如果所有的x[i]都>=y[i],那么y就是其中一个z,直接输出y就可以了!
代码:
#include<iostream>
#include<cstdio>
using namespace std;
string s1,s2;
int main()
{
cin>>s1>>s2;
for(int i=;i<s1.size();i++)
{
if(s1[i]<s2[i])
{
cout<<-<<endl;
return ;
}
}
cout<<s2<<endl;
return ;
}
Codeforces 801B - Valued Keys的更多相关文章
- AC日记——Valued Keys codeforces 801B
801B - Valued Keys 思路: 水题... 来,上代码: #include <cstdio> #include <cstring> #include <io ...
- Codeforces801B Valued Keys 2017-04-19 00:21 136人阅读 评论(0) 收藏
B. Valued Keys time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- 【codeforces 801B】Valued Keys
[题目链接]:http://codeforces.com/contest/801/problem/B [题意] 定义一个对两个字符串x,y的f(x,y)函数; 返回的是一个字符串; 这个返回的字符串的 ...
- Codeforces 830A. Office Keys (贪心二分 or DP)
原题链接:http://codeforces.com/contest/830/problem/A 题意:在一条数轴上分别有n个人和k把钥匙(n<=k),以及一个目的地,每个人要各自拿到一个钥匙后 ...
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)(A.思维题,B.思维题)
A. Vicious Keyboard time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) 题解【ABCDE】
A. Vicious Keyboard 题意:给你一个字符串,里面只会包含VK,这两种字符,然后你可以改变一个字符,你要求VK这个字串出现的次数最多. 题解:数据范围很小,暴力枚举改变哪个字符,然后c ...
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) A B C D 暴力 水 二分 几何
A. Vicious Keyboard time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 4.30-5.1cf补题
//yy:拒绝转载!!! 悄悄告诉你,做题累了,去打两把斗地主就能恢复了喔~~~ //yy:可是我不会斗地主吖("'▽'") ~~~那就听两遍小苹果嘛~~~ 五一假期除了花时间建模 ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) D. Office Keys time limit per test2 seconds 二分
D. Office Keys time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
随机推荐
- P1501 [国家集训队]Tree II(LCT)
P1501 [国家集训队]Tree II 看着维护吧2333333 操作和维护区间加.乘线段树挺像的 进行修改操作时不要忘记吧每个点的点权$v[i]$也处理掉 还有就是$51061^2=2607225 ...
- RequestBody使用
@RequestBody主要用来接收前端传递给后端的json字符串中的数据的(请求体中的数据的); GET方式无请求体,所以使用@RequestBody接收数据时,前端不能使用GET方式提交数据,而是 ...
- Linux Redhat 安装免费yum源
Linux Redhat 安装免费yum源 出处地址:http://www.cnblogs.com/nbartchen/p/8565816.html 1.查看是否安装相关包 rpm -qa|grep ...
- Nginx:论高并发,在座各位都是渣渣
NGINX 在网络应用中表现超群,在于其独特的设计.许多网络或应用服务器大都是基于线程或者进程的简单框架,NGINX突出的地方就在于其成熟的事件驱动框架,它能应对现代硬件上成千上万的并发连接. NGI ...
- 如何利用好github的问题
github对我来说真的是一个超好的平台,不过之前只是把它仓库来使用, 后来在大佬告诉我应该怎么使用github,今天就来总结下如何利用好github,让它发挥最大的威力. 1.把github当做百科 ...
- AppStore 添加回复
itunes connect 评论位置 1, 2, 添加用户权限:除了管理和客户支持可以回复.开发人员等只有只读权限
- 关于link标签的用法, 不声明rel=stylesheet则无效? 在ff中必须声明rel属性!
void 无效的, 空的; invalid: 无效的, void 和 invalid 在表示无效的时候, 是一样的, 等同的 the treaty (条约) was declared invalid ...
- [转]web高级开发的成长之路
读了这篇文章之后感觉蛮受启发的,在此分享一下,献给和我一样处于困惑的朋友. 正文如下: 本人也是coding很多年,虽然很失败,但也总算有点失败的心得,不过我在中国,大多数程序员都是像我一样,在一直走 ...
- POJ 2409 Let it Bead
思路 同这道题,只是颜色数从3变成c 代码 #include <cstdio> #include <algorithm> #include <cstring> #d ...
- springBoot 学习(总)
springBoot有个中文文档网址,应该是持续更新的. 别的资料 http://tengj.top/2017/02/26/springboot1/ http://412887952-qq-c ...