测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A10138. Queries on a String

编程题 普及/提高-

题目描述

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

输入格式

The first line of the input contains the string $s$ ( $1<=|s|<=10000$ ) 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 $l_{i}$ , $r_{i}$ and $k_{i}$ ( $1<=l_{i}<=r_{i}<=|s|,1<=k_{i}<=1000000$ ) — the description of the $i$ -th query.

输出格式

Print the resulting string $s$ after processing all $m$ queries.

输入输出样例

输入 #1
abacaba
2
3 6 1
1 4 2
输出 #1
baabcaa

说明/提示

The sample is described in problem statement.
上一题 去做题 下一题