Educational Codeforces Round 1 B. Queries on a String 暴力
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. It means that you should cyclically shift the substring s[li... ri] ki times. The queries should be processed one after another in the order they are given.
One operation of a cyclic shift (rotation) is equivalent to moving the last character to the position of the first character and shifting all other characters one position to the right.
For example, if the string s is abacaba and the query is l1 = 3, r1 = 6, k1 = 1 then the answer is abbacaa. If after that we would process the query l2 = 1, r2 = 4, k2 = 2 then we would get the string baabcaa.
Input
The first line of the input contains the string s (1 ≤ |s| ≤ 10 000) in its initial state, where |s| stands for the length of s. It contains only lowercase English letters.
Second line contains a single integer m (1 ≤ m ≤ 300) — the number of queries.
The i-th of the next m lines contains three integers li, ri and ki (1 ≤ li ≤ ri ≤ |s|, 1 ≤ ki ≤ 1 000 000) — the description of the i-th query.
Output
Print the resulting string s after processing all m queries.
Sample Input
abacaba
2
3 6 1
1 4 2
Sample Output
baabcaa
HINT
题意
给你一个字符串,然后有Q次操作,每次操作可以使得区间的字符串向右平移K个字符
然后问你最后的字符是什么模样
题解:
询问只有300个,所以可以直接暴力就好了
代码
#include<iostream>
using namespace std; int main()
{
string s1,s2;
cin>>s1;
s2=s1;
int q;cin>>q;
while(q--)
{
int l,r,k;cin>>l>>r>>k;
l--,r--;
int len = r-l+;k%=len;
for(int i=;i<len;i++)
{
s2[(i+k)%len+l]=s1[l+i];
}
for(int i=l;i<=r;i++)
s1[i]=s2[i];
}
cout<<s1<<endl;
}
Educational Codeforces Round 1 B. Queries on a String 暴力的更多相关文章
- Educational Codeforces Round 2 B. Queries about less or equal elements 水题
B. Queries about less or equal elements Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforc ...
- POJ-2926-Requirements&&Educational Codeforces Round 56G. Multidimensional Queries 【哈夫曼距离】
POJ2926 先学会这个哈夫曼距离的处理才能做 cf 的G #include <iostream> #include <stdio.h> #include <algor ...
- Educational Codeforces Round 2 B. Queries about less or equal elements
打开题目连接 题意:给2个数组(无序的)啊a,b,判断b数组中的每一个元素大于a数组中个数. ACcode: #include <iostream> #include <vector ...
- Educational Codeforces Round 4 B. HDD is Outdated Technology 暴力
B. HDD is Outdated Technology 题目连接: http://www.codeforces.com/contest/612/problem/B Description HDD ...
- Educational Codeforces Round 24 A 水 B stl C 暴力 D stl模拟 E 二分
A. Diplomas and Certificates time limit per test 1 second memory limit per test 256 megabytes input ...
- Educational Codeforces Round 22 B. The Golden Age(暴力)
题目链接:http://codeforces.com/contest/813/problem/B 题意:就是有一个数叫做不幸运数,满足题目的 n = x^a + y^b,现在给你一个区间[l,r],让 ...
- Educational Codeforces Round 15 A, B , C 暴力 , map , 二分
A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Educational Codeforces Round 6 B. Grandfather Dovlet’s calculator 暴力
B. Grandfather Dovlet’s calculator Once Max found an electronic calculator from his grandfather Do ...
- Educational Codeforces Round 94 (Rated for Div. 2) String Similarity、RPG Protagonist、Binary String Reconstruction、Zigzags 思维
题目链接:String Similarity 题意: 首先题目定义了两个串的相似(串的构成是0.1),如果两个串存在对于一个下标k,它们的值一样,那么这两个串就相似 然后题目给你一个长度为2n-1的串 ...
随机推荐
- source insight 的使用
一,新建工程:project-->new project --> ok--> ok--> close 完成项目的添加 二,sourceInsight的使用 1.跳转到标识定义处 ...
- Android开发中常见的设计模式
对于开发人员来说,设计模式有时候就是一道坎,但是设计模式又非常有用,过了这道坎,它可以让你水平提高一个档次.而在android开发中,必要的了解一些设计模式又是非常有必要的.对于想系统的学习设计模式的 ...
- jQuery-对Radio/CheckBox的操作集合
jQuery获取Radio选择的Value值 $("input[name='radio_name'][checked]").val(); //选择被选中Radio的Value值 $ ...
- Android SDK Manager 更新代理配置 ,蛋碎了
启动 Android SDK Manager ,打开主界面,依次选择「Tools」.「Options...」,弹出『Android SDK Manager - Settings』窗口: 在『Andro ...
- HDU 5881 Tea
Tea Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- Andriod中绘(画)图----Canvas的使用详解
http://blog.csdn.net/qinjuning/article/details/6936783
- bjfu1164 Parity Game
简单规律题.首先想到的是,若01串中1有n个,则可以通过操作,使串中1的个数变为n-1.n-2……1.0个:第2个想到的是,如果n为奇数,可以通过操作,使串中1的个数最多变为n+1,而若n为偶数,则无 ...
- 数据库表中MAX ID获取,确保每次调用没有重复工具类(NumberUtil)
下面这个类是获取数据库中一个字段的最大值.配置在数据库中. public class NoFactory { private final static Logger cLogger = Logger. ...
- qt 在指定区域添加图片
博客出处:http://www.devdiv.com/thread-39111-1-1.html 折腾了几天,终于实现了图片的淡出淡入的效果. 其实也应该是说实现了图片的淡入效果,因为淡出效果我暂时还 ...
- Python 学习笔记(四)正则、闭合、生成器
(一)正则表达式 基本规则: ^ 匹配字符串开始位置. $ 匹配字符串结束位置. \b 匹配一个单词边界. \d 匹配一个数字. \D 匹配一个任意的非数字字符. x? 匹配可选的x字符.换句话说,就 ...