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 ...
随机推荐
- Markdown语法学习(Github/git.oschina.net上README.md书写规范)(转)
晚上在更新git.oschina.net项目时,突然想知道README.md后缀的来源,于是搜了下,发现README.md使用了一种小标记语言Markdown的语法,于是简单的看了一个,特转载如下,为 ...
- centos6.5编译安装php7
1.安装依赖软件库: yum install -y libxml2-devel libtool* curl-devel libjpeg-devel libpng-devel freetype-deve ...
- Vijos 1308 埃及分数 - 迭代加深
描述 在古埃及,人们使用单位分数的和(形如1/a的, a是自然数)表示一切有理数.如:2/3=1/2+1/6,但不允许2/3=1/3+1/3,因为加数中有相同的.对于一个分数a/b,表示方法有很多种, ...
- C语言实现随机生成0或1
rand函数在产生随机数前,需要系统提供的生成伪随机数序列的种子,rand根据这个种子的值产生一系列随机数.如果系统提供的种子没有变化,每次调用rand函数生成的伪随机数序列都是一样的.srand(u ...
- Linux内核中的wake_lock[【转】
本文转载自:https://blog.csdn.net/wuyb2011/article/details/78542233?locationNum=11&fps=1 #include < ...
- centos6.8下源码编译安装tmux
1. 获取源码 git clone https://github.com/tmux/tmux.git ~/tmux 2. 准备工作 2.1 安装ncurses开发库 yum install ncurs ...
- Custom Quality Profiles in SonarQube
https://medium.com/ltunes/custom-quality-profiles-in-sonarqube-part-1-8754348b9369 Creating Custom Q ...
- CF1137C Museums Tour
思路 强连通分量的好题 对于每个博物馆,因为时间的限制条件,不好直接统计, 发现d很小,可以建出d层分层图,原图<u,v>的边变成<u,i>到<v,i+1>的边,& ...
- Ubuntu fcitx CPU占用率很高解决方法
在Ubuntu中,有时候电脑的风扇突然狂装,用 pidstat -u 5 1 命令查看后台应用的资源占用情况,发现fcitx的占用率接近百分之百. 原因是搜狗云输入的问题,关闭后,在用kill命令干掉 ...
- Docker:Service
Prerequisites Install Docker version 1.13 or higher. Get Docker Compose. On Docker for Mac and Docke ...