题意翻译

给定两个用空格分隔的字符串,分别取两字符串的任意非空前缀,将两前缀合并为一个新的字符串,求可行字典序最小的字符串。

题目描述

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.

输入输出样例

输入样例#1: 复制

harry potter
输出样例#1: 复制

hap
输入样例#2: 复制

tom riddle
输出样例#2: 复制

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的更多相关文章

  1. 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 ...

  2. 【Codeforces Round #455 (Div. 2) A】Generate Login

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举两个串的前缀长度就好. 组出来. 排序. 取字典序最小的那个. [代码] #include <bits/stdc++.h& ...

  3. Codeforces Round #455 (Div. 2)

    Codeforces Round #455 (Div. 2) A. Generate Login 题目描述:给出两个字符串,分别取字符串的某个前缀,使得两个前缀连起来的字符串的字典序在所有方案中最小, ...

  4. Codeforces Round #455

    Generate Login 第二个单词肯定只取首字母 Solution Segments 从1开始的线段和在n结束的线段各自凑一凑,剩下的转化为规模为n-2的子问题. Solution Python ...

  5. vue+ typescript 使用parcel 构建

    parcel 是一个零配置的前端构建工具,相比webpack 更快,同时使用简单以下是 一个简单的使用typescript 开发vue 应用,同时使用parcel 构建,同时集成了docker 构建, ...

  6. edusoho 支持同一账号多人同时登录

    文件: ./src/Topxia/WebBundle/Listener/UserLoginTokenListener.php 函数: public function onGetUserLoginLis ...

  7. 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 ...

  8. [转载] 构造linux 系统下免密码ssh登陆  _How to establish password-less login with SSH

    In present (post production) IT infrastructure many different workstations, servers etc. have to be ...

  9. (苹果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 ...

随机推荐

  1. 【CSS】CSS画矩形、圆、半圆、弧形、半圆、小三角、疑问框

    在网页中,常常会用到各种Icon,假设老是麻烦设计狮画出来不免有些不好意思,所以有时候我们也能够用CSS写出各种简单的形状.一来能够减轻他们的负担,二来也能够使用CSS替代图片.提高载入速度. 在网页 ...

  2. 0x63树的直径与最近公共祖先

    凉 bzoj1999 先把树的直径求出来,从左往右枚举,对于当前位置i,找到满足限制并且最远的点j,当前位置最大值就是max(i~j区间内除直径外的子树路径长度最大值,1~i的长度,j~n的长度) 然 ...

  3. bzoj3224: Tyvj 1728 普通平衡树(splay)

    3224: Tyvj 1728 普通平衡树 题目:传送门 题解: 啦啦啦啦又来敲个模版水经验啦~ 代码: #include<cstdio> #include<cstring> ...

  4. 国外物联网平台初探(二) ——微软Azure IoT

    平台定位 连接设备.其它 M2M 资产和人员,以便在业务和操作中更好地利用数据. 连接 IoT 设备 将所有设备连接到云,从这些设备接收大规模数据,以及管理这些设备的授权和限制. 在将设备连接到云和处 ...

  5. python spark 求解最大 最小 平均 中位数

    rating_data_raw = sc.textFile("%s/ml-100k/u.data" % PATH) print rating_data_raw.first() nu ...

  6. poj 3913(水)

    Description You have devised a new encryption technique which encodes a message by inserting between ...

  7. git如何解决冲突(master分支的上的冲突--太岁头上动土)

    欢迎加入前端交流群交流知识&&获取视频资料:749539640 git是什么就不废话了,详情点击 出现以下情况怎么解决? 有个index.ts文件 export const ENV = ...

  8. Python金融量化

    Python股票数据分析 最近在学习基于python的股票数据分析,其中主要用到了tushare和seaborn.tushare是一款财经类数据接口包,国内的股票数据还是比较全的 官网地址:http: ...

  9. 使用asp.net 开发的一个东平人才网招聘程序

    本人用asp.net 工作已经一两年时间了,在单位一般是做管理系统类的开发,针对的客户大都是政府机关,所以都是内网系统,虽然有成就感,但是无法再互联网上展示.虽然技术一般,但还是希望自己做一个网站在互 ...

  10. parseint和isNaN用法

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...