codeforces B. Pasha and String】的更多相关文章

Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given string. Pasha didn't like his present…
题意就是一次次翻转字符串 然后输出最终的字符串 暴力一发O(n*m)果然超时了 因为每次翻转的的都是a-1到对称位置 所以一个位置翻转两次等于没有操作 所以只需要记录一下len/2的位置前的操作次数 O(len/2)…… #include<stdio.h> #include<iostream> #include<algorithm> #include<math.h> #include<string.h> #include<string>…
题意:给定一个长度为len的字符序列,然后是n个整数,对于每一个整数ai, 将字符序列区间为[ai,len-ai+1]进行反转.求出经过n次反转之后的序列! /* 思路1:将区间为偶数次的直接去掉!对剩下的区间进行反转.超时了,智商上的压制... */ #include<iostream> #include<cstdio> #include<algorithm> #include<stack> #include<cstring> #include…
Codeforces Round #297 (Div. 2)B. Pasha and String Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  Solved: 2xx 题目连接 http://codeforces.com/contest/525/problem/B Description Pasha got a very beautiful string s for his birthday, the string consists o…
题目传送门 /* 题意:给出m个位置,每次把[p,len-p+1]内的字符子串反转,输出最后的结果 字符串处理:朴素的方法超时,想到结果要么是反转要么没有反转,所以记录 每个转换的次数,把每次要反转的反转就不超时了:) */ #include <cstdio> #include <algorithm> #include <cstring> using namespace std; ; const int INF = 0x3f3f3f3f; char s[MAXN]; i…
Pasha and String Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 525B Description Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. Th…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered…
Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Description Input Output Print exactly one integer — the beauty of the product of the strings. Sample Input 3aba Sample Output 3 题解:这个题的思维难度其实不大,需要维护什么东西很容易想到,或…
题目链接: http://codeforces.com/problemset/problem/710/E 题目大意: 问写N个字符的最小花费,写一个字符或者删除一个字符花费A,将当前的字符数量翻倍花费B. 题目思路: [动态规划][最短路] [动态规划]: 如果当前x不是2的倍数,那么一定需要单个字符增加或删除,而这个单个操作越靠后答案越优. dp(x)=a+min(dp(x-1),dp(x+1)) 如果当前x是2的倍数,那么有两种情况,一种是通过翻倍的方式获得,一种是通过累加的方式获得.只要比…
The Smallest String Concatenation 题目链接:http://codeforces.com/problemset/problem/632/C ——每天在线,欢迎留言谈论. 题目大意: 给你n个字符串,相加后 字典序最小 思路: 只需要保证每个相邻的两个字符串组合后 s1+s2>s2+s1 即可. 用sort()快速排序,最后依次输出即可! AC代码: #include <iostream> #include <string> #include &…