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的串 ...
随机推荐
- 如何修改因Informatica 8.6服务器IP而造资料库无法访问的问题
原因分析解决及如何避免(PowerCenter 8.6.1) 前几天同事安装了个PowerCenter8.6.1做测试,出去了几天回来后Administration Console无法登入了.同事用的 ...
- Android-监听sdcard状态
public class MyService extends Service { private static final String TAG = "MyService"; Fi ...
- 滑屏 H5 开发实践九问
滑屏的交互形式自从在 H5 中流行起来,便广泛应用在产品宣传.广告.招聘和活动运营等场景中,作为微信朋友圈广告惯用的形式,其影响力更是得到了强化与放大.如今滑屏H5可谓玲琅满目,数不尽数. 作为一个 ...
- android 官网处理图片 代码
/** * 获取压缩后的图片 (官网大图片加载对应代码) * * @param res * @param resId * @param reqWidth * 所需图片压缩尺寸最小宽度 * @param ...
- android判断当前网络状态及跳转到设置界面
今天,想做这个跳转到网络设置界面, 刚开始用 intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS); 不料老是出现settings.Wirele ...
- 【转】VC6.0附带小工具软件一览
)ActiveX Control Test Container称为"ActiveX 控件测试容器",顾名思义,此工具的主要功能就是测试ActiveX 控件,可以通过改变Active ...
- 编译器对C++ 11变参模板(Variadic Template)的函数包扩展实现的差异
编译器对C++ 11变参模板(Variadic Template)的函数包扩展实现的差异 题目挺绕口的.C++ 11的好东西不算太多,但变参模板(Variadic Template)肯定是其中耀眼的一 ...
- ColorNote[动态][log]
Windows 应用商店上传日志 [ColorNote In Windows APP Store Log]: ColorNote v1.0 2012/12/2 ColorNote v1.1 2012/ ...
- 【转】浅析C语言的非局部跳转:setjmp和longjmp
转自 http://www.cnblogs.com/lienhua34/archive/2012/04/22/2464859.html C语言中有一个goto语句,其可以结合标号实现函数内部的任意跳转 ...
- Spring InitializingBean and DisposableBean example
In Spring, InitializingBean and DisposableBean are two marker interfaces, a useful way for Spring to ...