CF518A Vitaly and Strings

    • 94通过
    • 308提交
  • 题目来源 CodeForces 518A
  • 评测方式 RemoteJudge
  • 标签 字符串
  • 难度 入门难度
  • 时空限制 1000ms / 256MB

题解

  • 提示:收藏到任务计划后,可在首页查看。
  • 最新讨论 显示

    推荐的相关题目 显示

    题意翻译

    维塔利是一个勤奋的学生,在大学阶段,他从来没有逃过一堂课。他总是按时做作业,并顺利通过考试。

    在上一节课,老师给了他两个字符串s和t。这两个字符串的长度相同,由小写英文字母组成,字符串s的字典序比串t小。维塔利想知道是否有这样的字符串:字典序比字符串s大,同时字典序小于串t。此字符串也应包括小写英文字母和相同的长度。

    让我们帮维塔利解决这个简单的问题!

    第一行包含字符串s(1≤|s| ≤100),由小写英文字母组成。这里,|s| 表示字符串s的长度。

    第二行包含字符串t(|t|=|s| ),由小写英文字母组成。

    保证字符串s和t的长度是相同的,字符串s字典顺序小于字符串t。

    如果满足要求的字符串不存在,则输出No such string。

    如果这样的字符串存在,就输出任何一个满足条件的字符串。( 也只能由小写英文字母a-z组成)

    Translated by @馒头精

    题目描述

    Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time.

    During the last lesson the teacher has provided two strings $ s $ and $ t $ to Vitaly. The strings have the same length, they consist of lowercase English letters, string $ s $ is lexicographically smaller than string $ t $ . Vitaly wondered if there is such string that is lexicographically larger than string $ s $ and at the same is lexicographically smaller than string $ t $ . This string should also consist of lowercase English letters and have the length equal to the lengths of strings $ s $ and $ t $ .

    Let's help Vitaly solve this easy problem!

    输入输出格式

    输入格式:

    The first line contains string $ s $ ( $ 1<=|s|<=100 $ ), consisting of lowercase English letters. Here, $ |s| $ denotes the length of the string.

    The second line contains string $ t $ ( $ |t|=|s| $ ), consisting of lowercase English letters.

    It is guaranteed that the lengths of strings $ s $ and $ t $ are the same and string $ s $ is lexicographically less than string $ t $ .

    输出格式:

    If the string that meets the given requirements doesn't exist, print a single string "No such string" (without the quotes).

    If such string exists, print it. If there are multiple valid strings, you may print any of them.

    输入输出样例

    输入样例#1: 复制
    a
    c
    
    输出样例#1: 复制
    b
    
    输入样例#2: 复制
    aaa
    zzz
    
    输出样例#2: 复制
    kkk
    
    输入样例#3: 复制
    abcdefg
    abcdefh
    
    输出样例#3: 复制
    No such string
    

    说明

    String $ s=s_{1}s_{2}...\ s_{n} $ is said to be lexicographically smaller than $ t=t_{1}t_{2}...\ t_{n} $ , if there exists such $ i $ , that $ s_{1}=t_{1},s_{2}=t_{2},...\ s_{i-1}=t_{i-1},s_{i}<t_{i} $ .

    提示
    标程仅供做题后或实在无思路时参考。
    请自觉、自律地使用该功能并请对自己的学习负责。
    如果发现恶意抄袭标程,将按照I类违反进行处理。