国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Codeforces 598B Queries on a String(rotate(begin,mid,end))

2019-11-08 02:53:49
字體:
來源:轉載
供稿:網友

B. Queries on a String

time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output 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 test(s) input abacaba 2 3 6 1 1 4 2 output baabcaa 水題 循環移位

#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;char a[10005];int main(){ int n,l,r,k; scanf("%s",a); scanf("%d",&n); while(n--){ scanf("%d %d %d",&l,&r,&k); k=k%(r-l+1); rotate(a+l-1,a+r-k,a+r); } printf("%s",a); return 0;}
上一篇:spring

下一篇:文章標題

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 台前县| 桐梓县| 舒兰市| 诏安县| 百色市| 饶河县| 九江市| 孟津县| 锡林浩特市| 留坝县| 镇原县| 兰溪市| 漠河县| 西丰县| 寿光市| 乡宁县| 彭州市| 介休市| 伊金霍洛旗| 巴林左旗| 茌平县| 嘉鱼县| 济源市| 讷河市| 岢岚县| 澜沧| 武功县| 溆浦县| 闸北区| 玉溪市| 麟游县| 穆棱市| 宁乡县| 玉山县| 商南县| 怀化市| 临沭县| 东乌珠穆沁旗| 安乡县| 兴宁市| 托里县|