【题目链接】:http://codeforces.com/contest/709/problem/C

【题意】

让你改变一个字符串的子集(连续的一段);
->这一段的每个字符的字母都变成之前的一个;
即b->a或是a>z;
然后使得剩下的字符串的字典序最小;

【题解】

优先更改前面的字符;
所以遇到第一个不是a的字符->改!
从那个字符开始只要不是a就一直改就好;
hack点;
有说
exactly once->也就是说

aaa
不能全都不改;
把最后那个a改成z(损失最小)
永远不要低估CF的C题。。

【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%lld",&x)
#define ref(x) scanf("%lf",&x)typedef pair<int, int> pii;
typedef pair<LL, LL> pll;const int dx[9] = { 0,1,-1,0,0,-1,-1,1,1 };
const int dy[9] = { 0,0,0,-1,1,-1,1,-1,1 };
const double pi = acos(-1.0);
const int N = 1e5+1000;char s[N];
int len;int main()
{//freopen("F:\\rush.txt", "r", stdin);bool fi = false;scanf("%s", s + 1);len = strlen(s + 1);rep1(i, 1, len){if (s[i] == 'a') continue;int j = i;while (j + 1 <= len && s[j + 1] != 'a') j++;rep1(k, i, j) s[k]--;fi = true;break;}if (!fi) s[len]='z';printf("%s", s + 1);//printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);return 0;
}

转载于:https://www.cnblogs.com/AWCXV/p/7626483.html

【codeforces 709C】Letters Cyclic Shift相关推荐

  1. Codeforces Problem 708A Letters Cyclic Shift(implementation)

    此文章可以使用目录功能哟↑(点击上方[+]) 比赛链接→AIM Tech Round 3 (Div. 1)  Codeforces Problem 708A Letters Cyclic Shift ...

  2. 【CodeForces - 144C】Anagram Search(尺取,滑窗问题,处理字符串计数)

    题干: A string t is called an anagram of the string s, if it is possible to rearrange letters in t so ...

  3. 【CodeForces - 574B】Bear and Three Musketeers (枚举边,思维,优秀暴力)

    题干: Do you know a story about the three musketeers? Anyway, you will learn about its origins now. Ri ...

  4. 【CodeForces - 608C】Chain Reaction (二分 或 dp ,思维)

    题干: 题目大意: 题意是在一条直线上坐落着不同位置的灯塔,每一个灯塔有自己的power level,当作是射程范围.现在从最右边的灯塔开始激发,如果左边的灯塔在这个灯塔的范围之内,那么将会被毁灭.否 ...

  5. 「一题多解」【CodeForces 85D】Sum of Medians(线段树 / 分块)

    题目链接 [CodeForces 85D]Sum of Medians 题目大意 实现一个setsetset,支持插入,删除,求∑a5k+3∑a5k+3\sum a_{5k+3}.注意,setsets ...

  6. 【CodeForces 997C】Sky Full of Stars(组合计数)

    题目链接:[CodeForces 997C]Sky Full of Stars 官方题解:Codeforces Round #493 - Editorial 题目大意:有一个n×nn×nn\times ...

  7. CF708A Letters Cyclic Shift 题解

    CF708A Letters Cyclic Shift 题目链接:CF708A Letters Cyclic Shift 题意:一次变换指将字母变为它前面一个字母,例如a变成z,b变成a,给定字符串, ...

  8. 【37.50%】【codeforces 745B】Hongcow Solves A Puzzle

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  9. 【CodeForces - 155C】Hometask (字符串,思维,贪心,熟悉句式)(总结)

    题干: Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the ...

  10. 【codeforces 752C】Santa Claus and Robot

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

最新文章

  1. 目标检测算法基础概念:边框回归和NMS
  2. springboot2新版springcloud微服务,带你了解不一样的springboot2
  3. reactnative 获取定位_react native 获取地理位置的方法示例
  4. SAP UI5 different cache results
  5. 易语言怎么判断文件是否一样_怎么判断专利代理人或专利代理机构是否靠谱?...
  6. 几行代码轻松实现瀑布流显示。
  7. 20145308刘昊阳 20145302张薇《信息安全系统设计基础》实验五:网络通信 实验报告...
  8. SpringCloud工作笔记063---Java 手机验证码生成_存储到redis
  9. (原创)一个简洁通用的调用DLL函数的帮助类
  10. java addmonth_JAVA:int month = n.get(Calendar.MONTH)+1;为何要加1?
  11. git 存在多个commit 时将修改,追加到某次commit 上
  12. CorelDRAW2020下载使用教程详解
  13. imatest白平衡测试结果解析
  14. [开箱即用]一个用PHP实现的文字翻译,支持谷歌、百度、小牛翻译sdk(工厂抽象模式)
  15. 不同速度流体的剪切形成不同尺度的漩涡,看起来很像分形。
  16. NYOJ 33 蛇形填数
  17. excel填充序列_猴哥讲述:excel的自动填充功能——自动填充单元格
  18. opencv 使用 GPU 加速
  19. 弘辽科技:淘宝收藏加购在哪里看?如何提升收藏加购数量?
  20. 电信10兆指的是多少Mbps

热门文章

  1. spark java jar 依赖_spark提交依赖jar包的解决方法
  2. NYOJ 表达式求最值305
  3. 循环buffer的实现_Go语言源码阅读之bytes.Buffer
  4. c语言文件操作rewand,C语言程序设计第章概述.ppt
  5. 十大排序算法——插入排序法(C语言)
  6. 深度学习、机器学习、自然语言处理NLP优秀文章整理
  7. SLAM--位姿图优化和PnP求解
  8. DeepRacer 资源合集
  9. 互联网硅谷投资教父 保罗·格雷厄姆 Paul Graham
  10. Servlet和JSP