CodeForces 709C Letters Cyclic Shift】的更多相关文章

题意:给定一个字符串,让你把它的一个子串字符都减1,使得总字符串字典序最小. 析:由于这个题是必须要有一个字串,所以你就要注意这个只有一个字符a的情况,其他的就从开始减 1,如果碰到a了就不减了,如果到最后一位了还没开始减, 就减最后一位. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <c…
贪心. 肯定是两个$a$之间的那些字符都$-1$,没有$a$就全部$-1$.如果输入的串全是$a$,那么把最后一个$a$改成$z$. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #inc…
A. Letters Cyclic Shift time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty su…
题目链接: C. Letters Cyclic Shift 题意: 现在一串小写的英文字符,每个字符可以变成它前边的字符即b-a,c-a,a-z这样,选一个字串变换,使得得到的字符串字典序最小; 思路: 贪心,尽量让前边的字典序变小; AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #inclu…
A. Letters Cyclic Shift 题目连接: http://www.codeforces.com/contest/708/problem/A Description You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z'…
[题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一个; 即b->a或是a>z; 然后使得剩下的字符串的字典序最小; [题解] 优先更改前面的字符; 所以遇到第一个不是a的字符->改! 从那个字符开始只要不是a就一直改就好; hack点: 有说 exactly once->也就是说 像 aaa 不能全都不改; 把最后那个a改成z(损失最…
 题目链接: http://codeforces.com/problemset/problem/708/A 题目大意: 从字符串s中挑选出一个子串(非空),将该子串中的每个字母均替换成前一个字母,如'b'换成'a','c'换成'b',以此类推,特别的,'a'要换成'z',问经过一次转换之后,字典序最小的字符串s为多少.注意“exactly one non-empty substring”这就意味着全'a'串也要变,即字符串"aaa",替换其中的字母(会使得字典序比原来大),但又要使字典…
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' 'y' 'x' 'b' 'a' 'z'. In other words, each character is replaced with the previous characte…
C. Letters Cyclic Shift time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty su…
A. Hongcow Learns the Cyclic Shift 题目连接: http://codeforces.com/contest/745/problem/A Description Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how t…
Largest Smallest Cyclic Shift 题目来源: Atcoder Code Festival 2017 Qual B Problem F 题目大意: 有\(X\)个字符'a',\(Y\)个字符'b',\(Z\)个字符'c'.用它们组成字符串,求最小表示的最大值. 思路: 贪心.首先将所有由单个字符构成的字符串插入到一个multiset<string>中,每次选取最小串\(s\)和最大串\(t\).此时最小表示一定是由\(s\)开头的,而将\(t\)接在\(s\)后面可以让…
2019-05-18 09:51:19 加油,加油,fightting !!! https://www.cnblogs.com/ECJTUACM-873284962/p/6375011.html 全为aaaaaa的情况一定要注意 #include <bits/stdc++.h> using namespace std; int main() { string s; int j, i; ; cin >> s; ; i < s.length(); i++) { if (s[i]…
F. Letters Removing time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Petya has a string of length n consisting of small and large English letters and digits. He performs m operations. Each…
Letters Removing 题意:给你一个长度为n的字符串,然后进行m次删除操作,每次删除区间[l,r]内的某个字符,删除后并且将字符串往前补位,求删除完之后的字符串. 题解:先开80个set 将每个字符对应的下标存入空间, 然后每次删除了一个字符之后就将字符串的相应位置改成一个不会产生干扰的字符(我这里使用的是'.'). 并且在线段树的相应位置标记一下.然后每次删除时候的左右区间就用2分区查找. 找到位置pos 使得 [1,pos]的值等于 pos - l, 这样就可以找到相应的区间了.…
题意 给出nnn个顶点和mmm条边,求这个图中环的个数 思路 利用并查集的性质,环上的顶点都在同一个集合中 在输入的时候记录下来每个顶点的度数,查找两个点相连,且度数均为222的点,如果这两个点的父节点相同,表示这两个点在一个环中,环的个数+1+1+1 AC代码 /************************************************************************* > File Name: E.cpp > Author: WZY > QQ:…
传送门 题意:给你x个a,y个b,z个c,显然这些字符可以拼成若干字符串,然后求这些字符串中最小表示法表示出来的最大的那一个. 解法:贪心思想,用multiset维护现在拼成的字串,每次取一个最小的和一个最大的拼在一起,最后剩下的就是答案. 代码如下: #include<bits/stdc++.h> using namespace std; int a,b,c; multiset<string>s; int main(){ scanf("%d%d%d",&…
题目大意:给你\(A\)个a,\(B\)个b,\(C\)个c,要你构造一个字符串,使它的最小循环表示法最大.求这个表示法.解题思路:不知道怎么证,但把a.b.c当做单独的字符串扔进容器,每次把字典序最小的和字典序最大的两个字符串合并就是答案.容器用multiset即可. C++ Code: #include<cstdio> #include<set> #include<string> using namespace std; multiset<string>…
虽然每次给一个区间,但是可以看作在区间内进行数个点操作,同样数列下标是动态变化的,如果我们将每个字符出现看作1,被删除看作0,则通过统计前缀和就能轻松计算出两个端点的位置了!这正是经典的树状数组操作 需要注意的是,即使每次找到了两个端点,如果只是朴素总左到右遍历会TLE,所以可以给每个字符开一个set,每个set储存字符出现的位置. #include <iostream> #include <cstdio> #include <cstring> #include <…
rating又掉下去了.好不容易蓝了.... A..没读懂题,wa了好几次,明天问队友补上... B. Checkpoints 题意:一条直线上n个点x1,x2...xn,现在在位置a,求要经过任意n-1个点的最小路程 题解:分类讨论,乱搞搞总会出来的,我大概写的很笨…… #include <bits/stdc++.h> using namespace std; typedef long long ll; ]; ll cal(ll x, ll a, ll z) { +(z-a) , (z-a)…
A......................................................................................... 题目链接→Codeforces Problem 712A Memory and Crow [题意]有n个数b1, b2, ..., bn a1, a2, ..., an是通过等式ai = bi - bi + 1 + bi + 2 - bi + 3....(±)bn得到的 现给你a1, a2, ..., an这n个数,…
A. Juicer time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixe…
题目链接:(做出几道说几道^_^) A.Juicer B.Checkpoints C.Letters Cyclic Shift 思路: A题每次加上橘子的体积,超过就清零,计数器加1 B题比较 (loc[0]——最左端,loc[n]——最右端,a当前位置,loc[1]——次左端,loc[n-1]——次右端) a-loc[1]+loc[n-1]-loc[1], loc[n-1]-a+loc[n-1]-loc[1], a-loc[2]+loc[n]-loc[2], loc[n]-a+loc[n]-l…
B. Queries on a String Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/598/problem/B Description You are given a string s and should process m queries. Each query is described by two 1-based indices li, ri and integer ki. I…
A. Friends Meeting time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Two friends are on the coordinate axis Ox in points with integer coordinates. One of them is in the point x1 = a, another…
A. Hongcow Learns the Cyclic Shift time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Bein…
 Little Elephant and Chess Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 259A Description The Little Elephant loves chess very much. One day the Little Elephant and his friend decided…
C. Little Elephant and Shifts Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/220/C Description The Little Elephant has two permutations a and b of length n, consisting of numbers from 1 to n, inclusive. Let's de…
D. Serega and Fun Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/455/problem/D Description Serega loves fun. However, everyone has fun in the unique manner. Serega has fun by solving query problems. One day Fedor came up w…
A. Hongcow Learns the Cyclic Shift time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Bein…
题目链接:http://codeforces.com/contest/731/problem/D D. 80-th Level Archeology time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Archeologists have found a secret pass in the dungeon of one of t…