CF598B.Queries on a String

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a string ss and should process mm queries. Each query is described by two 1-based indices lil_{i} , rir_{i} and integer kik_{i} . It means that you should cyclically shift the substring s[li... ri]s[l_{i}...\ r_{i}] kik_{i} 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 ss is abacaba and the query is l1=3,r1=6,k1=1l_{1}=3,r_{1}=6,k_{1}=1 then the answer is abbacaa. If after that we would process the query l2=1,r2=4,k2=2l_{2}=1,r_{2}=4,k_{2}=2 then we would get the string baabcaa.

输入格式

The first line of the input contains the string ss ( 1<=s<=100001<=|s|<=10000 ) in its initial state, where s|s| stands for the length of ss . It contains only lowercase English letters.

Second line contains a single integer mm ( 1<=m<=3001<=m<=300 ) — the number of queries.

The ii -th of the next mm lines contains three integers lil_{i} , rir_{i} and kik_{i} ( 1<=li<=ri<=s,1<=ki<=10000001<=l_{i}<=r_{i}<=|s|,1<=k_{i}<=1000000 ) — the description of the ii -th query.

输出格式

Print the resulting string ss after processing all mm queries.

输入输出样例

  • 输入#1

    abacaba
    2
    3 6 1
    1 4 2
    

    输出#1

    baabcaa
    

说明/提示

The sample is described in problem statement.

首页