CF909A Generate Login
题意翻译
给定两个用空格分隔的字符串,分别取两字符串的任意非空前缀,将两前缀合并为一个新的字符串,求可行字典序最小的字符串。
题目描述
The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the full name. Typically there are multiple possible logins for each person.
You are given the first and the last name of a user. Return the alphabetically earliest login they can get (regardless of other potential Polygon users).
As a reminder, a prefix of a string ss is its substring which occurs at the beginning of ss : "a", "ab", "abc" etc. are prefixes of string "{abcdef}" but "b" and 'bc" are not. A string aa is alphabetically earlier than a string bb , if aa is a prefix of bb , or aa and bb coincide up to some position, and then aa has a letter that is alphabetically earlier than the corresponding letter in bb : "a" and "ab" are alphabetically earlier than "ac" but "b" and "ba" are alphabetically later than "ac".
输入输出格式
输入格式:
The input consists of a single line containing two space-separated strings: the first and the last names. Each character of each string is a lowercase English letter. The length of each string is between 1 and 10, inclusive.
输出格式:
Output a single string — alphabetically earliest possible login formed from these names. The output should be given in lowercase as well.
输入输出样例
tom riddle
tomr
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
string s1,s2;
int len1,len2,pos1,pos2;
int main(){
cin>>s1>>s2;
len1=s1.length()-;
len2=s2.length()-;pos1=;
while(s1[pos1]<s2[pos2]&&pos1<=len1) pos1++;
if(pos1){
for(int i=;i<pos1;i++) cout<<s1[i];
cout<<s2[];
return ;
}
}
CF909A Generate Login的更多相关文章
- Codeforces Round #455 (Div. 2) A. Generate Login【贪心】
A. Generate Login time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- 【Codeforces Round #455 (Div. 2) A】Generate Login
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举两个串的前缀长度就好. 组出来. 排序. 取字典序最小的那个. [代码] #include <bits/stdc++.h& ...
- Codeforces Round #455 (Div. 2)
Codeforces Round #455 (Div. 2) A. Generate Login 题目描述:给出两个字符串,分别取字符串的某个前缀,使得两个前缀连起来的字符串的字典序在所有方案中最小, ...
- Codeforces Round #455
Generate Login 第二个单词肯定只取首字母 Solution Segments 从1开始的线段和在n结束的线段各自凑一凑,剩下的转化为规模为n-2的子问题. Solution Python ...
- vue+ typescript 使用parcel 构建
parcel 是一个零配置的前端构建工具,相比webpack 更快,同时使用简单以下是 一个简单的使用typescript 开发vue 应用,同时使用parcel 构建,同时集成了docker 构建, ...
- edusoho 支持同一账号多人同时登录
文件: ./src/Topxia/WebBundle/Listener/UserLoginTokenListener.php 函数: public function onGetUserLoginLis ...
- Linux - SSH - Password-less login - generate public key - migrate data without password between two VM servers
SUMMARY:two server : A , Bsource server : Adestination server : Bthe steps of migrate data from A to ...
- [转载] 构造linux 系统下免密码ssh登陆 _How to establish password-less login with SSH
In present (post production) IT infrastructure many different workstations, servers etc. have to be ...
- (苹果AppleWWDRCA.cer证书过期)Failed to locate or generate matching signing assets
从2月14号开始,上传AppStore会碰到:Failed to locate or generate matching signing assets 字数462 阅读13571 评论16 喜欢61 ...
随机推荐
- windows XP下Python2.7包管理工具安装-setuptool,pip、distribute、nose、virtualenv
在Python开发中为了对项目进行管理和调试.必须安装一些特定的软件包.据说业内这个叫做yak shaving-做一个非常酷非常绚丽的Python项目之前,必须做的一些枯燥无味的准备工作.本文介绍了s ...
- [HDU 1421]搬寝室(富有新意的DP)
题目地址:pid=1421" target="_blank">http://acm.hdu.edu.cn/showproblem.php? pid=1421 题目大 ...
- Design库,所有控件的使用
导入地址com.android.support:design:23.2.0..输入design搜索到确认就可以. 布局中android.support.design.widget.XXX,调用控件 控 ...
- 【iOS开发-80】Quartz2D画图简单介绍:直线/圆形/椭圆/方形以及上下文栈管理CGContextSaveGState/CGContextRestoreGState
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvd2Vpc3ViYW8=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA ...
- 2016.04.18,英语,《Vocabulary Builder》Unit 15
term/termin, comes from the Latin verb terminare, 'to limit, bound, or set limits to', or the relate ...
- camera table表编译
mmm -j8 vendor/mediatek/proprietary/hardware/mtkcam/v1/common/paramsmgr/ 2>&1 | tee ft.lib.lo ...
- javascript设计模式-掺元类
有一种重用代码的方法不需要用到严格的继承.如果想把一个函数用到多个类中,可以通过扩充的方式让这些类共享该函数.其实际做法大大体为:先创建一个包含各种通用方法的类,然后再用它扩充其他的类.这种方式就叫做 ...
- Educational Codeforces Round 35
Nearest Minimums 相同的数里最小的数里的最小距离 Solution Two Cakes Solution Three Garlands 瞎比试 Solution Inversion C ...
- Linux下打包、压缩和解压
命令使用:tar 主选项+辅选项 压缩后文件名 要压缩的文件 -c 建立压缩文件(常用) -x 解压(常用) -t 查看压缩文件(常用) -r 向压缩文件末尾追加文件 -u 更新一个压缩包中的文 ...
- Android 自定义控件——图片剪裁
如图: 思路:在一个自定义View上绘制一张图片(参照前面提到的另一篇文章),在该自定义View上绘制一个自定义的FloatDrawable,也就是图中的浮层.绘制图片和FloatDrawable的交 ...
