题意翻译

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

题目描述

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. javascript的==和===,以及if(xxx)总结

    转载请注明 本文出自:http://blog.csdn.net/nancle 首先说==和=== 首先说明一个非常特殊的值NaN, typeof(Nav)得到'number',可是NaN不等于不论什么 ...

  2. 使用RabbitMQ放置自己定义对象(不借助序列化工具,比如protobuffer)V2.0

    怎样使用RabbitMQ盛放自己定义的对象呢?一般都会使用序列化工具在投放之前转换一次.从MQ取回的时候再逆序列化还原为本地对象.这里使用C++自带的强制类型装换,将本地对象的内存模型当做自然的序列化 ...

  3. hdoj--5621--KK's Point(简单数学)

    KK's Point Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total ...

  4. 如何删除github wiki page

    title: 如何删除github wiki page toc: false date: 2019-02-23 10:08:41 categories: methods tags: github wi ...

  5. POJ 2406 KMP next数组的应用

    题意:让你找最小重复串的个数 加深KMP中对next数组的理解 #include <cstdio> #include <cstring> using namespace std ...

  6. A - George and Accommodation

    Problem description George has recently entered the BSUCP (Berland State University for Cool Program ...

  7. 兼容各个浏览器的jquyer zclip复制文本插件 无效的解决办法

    项目中使用点击文本复制功能,用了这个兼容各个浏览器的插件,但是发现放在最前面正常,放到嵌套的html中就失效. 解决办法: <span style="position: relativ ...

  8. Android Fragment 初步解析

    Fragment经常在我们的开发中见到,但是自我感觉对Fragment的理解还是处于初级的阶段,接下来我将用几篇文章尽量深的解析Fragment 让我们开始吧!!! Fragment的生命周期 Fra ...

  9. PHP在Linux的Apache环境下乱码解决方法

    在windows平台编写的php程序默认编码是gb2312 而linux和apche默认的编码都是UTF-8 所以windows平台编写的php程序传到linux后,浏览网页中文都是乱码. 如果手工将 ...

  10. 图表库 - Highchart / Echart

    当前主要使用HighChart和Echart图表库,都基于Jquery,需要先引用Jquery. 实际问题:引入Jquery需在图表库前,否则报错. HighChart官网:https://www.h ...