Lexicographic Order

(https://codeforces.com/group/L9GOcnr1dm/contest/422381/problem/L)

比较简单的一道题目,主要理解什么是字典序就好了

它要求我们以给定的字符串去构建一个最大字典序的字符串且长度不超过m

那么我们能知道最大字典序(小写的)肯定就是‘z’所以我们需要添加m-n个‘z’即可。

再然后我们需要满足构造的新字符串的字典序要小于原字符串,那么我们只需要修改原字符串的最后一个字母

PS:这里要考虑最后一个字符是否是‘a’的情况

如果是,那么直接删去‘a’即可构造完毕,不需要再添加‘z’(特殊情况!)

反之要添加‘z’;

Acode

string s = "abcdefghijklmnopqrstuvwxyz";
int main() {
int n,m;cin >> n >> m;
string aim;cin >> aim;
if(aim[aim.size()-1] == 'a'){
for (int i = 0; i < aim.size()-1; i++) {
cout << aim[i];
}
cout << endl;
}else{
for (int i = 0; i < s.size(); i++) {
if(s[i] == aim[aim.size()-1]){
aim[aim.size()-1] = s[i-1];break;
}
}
string ad;
for (int i = 1; i <= m-n; i++) {
ad += 'z';
}
string ans = aim + ad;
cout << ans << endl;
}
return 0;
}

Lexicographic Order的更多相关文章

  1. HDU 3999 The order of a Tree

    The order of a Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  2. hdu3999The order of a Tree (二叉平衡树(AVL))

    Problem Description As we know,the shape of a binary search tree is greatly related to the order of ...

  3. <hdu - 3999> The order of a Tree 水题 之 二叉搜索的数的先序输出

    这里是杭电hdu上的链接:http://acm.hdu.edu.cn/showproblem.php?pid=3999  Problem Description: As we know,the sha ...

  4. HDU 3999 The order of a Tree (先序遍历)

    The order of a Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  5. hdu3999-The order of a Tree (二叉树的先序遍历)

    http://acm.hdu.edu.cn/showproblem.php?pid=3999 The order of a Tree Time Limit: 2000/1000 MS (Java/Ot ...

  6. 二叉排序树:HUD3999-The order of a Tree(二叉排序树字典序输出)

    The order of a Tree Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...

  7. The order of a Tree

    The order of a Tree Problem Description As we know,the shape of a binary search tree is greatly rela ...

  8. [LeetCode] Group Shifted Strings 群组偏移字符串

    Given a string, we can "shift" each of its letter to its successive letter, for example: & ...

  9. POJ No.3617【B008】

    [B007]Best Cow Line[难度B]———————————————————————————————————————————————— [Description    支持原版从我做起!!! ...

  10. Simple Network Management Protocol - SNMP Tutorial

    30.9 Simple Network Management Protocol Network management protocols specify communication between t ...

随机推荐

  1. InnoDB和MyISAM的区别(超详细)

    1.事务 InnoDB支持事务,MyISAM不支持,对于InnoDB每一条SQL语言都默认封装成事务,自动提交,这样会影响速度,所以最好把多条SQL语言放在begin和commit之间,组成一个事务: ...

  2. Oracle_20200416

    PLSQL 新建普通用户 1.使用system登录 2.File-->NEW-->SQL WINDOW 3.执行语句 --创建用户 --create user 用户名 identified ...

  3. Buuoj 被嗅探的流量

    Buuoj 被嗅探的流量 这个点进去之后看到了很像flag的内容 这个好像就是 也可以右键Analyse→Follow→TCP Stream或HTTP stream

  4. PASS模型小程序设计阶段-里程碑第三组

    班级网址 https://edu.cnblogs.com/campus/zjcsxy/SE2020 作业要求 https://edu.cnblogs.com/campus/zjcsxy/SE2020/ ...

  5. jmeter-脚本制作

    HTTP请求 默认端口号 HTTP默认端口号:80 HTTPS默认端口:443 数据来源 通过网络抓包软件(Fiddler.Charles等).接口文档数据 脚本制作+结果 录制脚本 badbod 录 ...

  6. [复现]DASCTF Sept X 浙江工业大学秋季挑战赛-PWN

    hehepwn 一开始泄露stack地址,然后写入shellcode返回到shellcode执行 from pwn import * context.os = 'linux' context.log_ ...

  7. nginx Redis 不能访问问题

    开始以为     proxy_cookie_path    /report/     /; 没有配置 配置后还是访问了,老的session 就过期 本地代理主程序,访问本地的 /report/ 可以 ...

  8. 使用MyBatis时需要注意到的事情------执行添加、修改和删除操作时,一定要记得提交事务

    今天在重写添加操作代码时,发现自己写的代码没有任何报错,使用断点进行查询,发现一切正常,但是注册使用的数据就是无法添加到数据库里面 然后就去之前看过的视频里面去找错误,就发现这样一个小细节: 在视频里 ...

  9. 基于深度学习的农作物叶片病害检测系统(UI界面+YOLOv5+训练数据集)

    摘要:农作物叶片病害检测系统用于智能检测常见农作物叶片病害情况,自动化标注.记录和保存病害位置和类型,辅助作物病害防治以增加产值.本文详细介绍基于YOLOv5深度学习模型的农作物叶片病害检测系统,在介 ...

  10. DDD架构中的领域是什么?

    DDD架构中的领域是什么? ​ 我们经常说到DDD分层架构(领域驱动设计),那么究竟什么是DDD架构?如果去网上查通常会告诉你告诉你区别于过去的三层架构思想,DDD(领域驱动设计)是一种四层架构,一般 ...