CF598B.Queries on a String
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
给你一个字符串 s,你需要处理 m 个查询。每个查询由两个基于 1 的下标 li、ri 和一个整数 ki 描述。其含义是:对子串 s[li…ri] 进行 ki 次循环移位(旋转)。这些查询需按给定顺序依次处理。
一次循环移位(旋转)操作等价于将最后一个字符移到第一个字符的位置,并将其余所有字符向右移动一位。
例如,若字符串 s 为 abacaba,且查询为 l1=3, r1=6, k1=1,则结果为 abbacaa。若在此之后再处理查询 l2=1, r2=4, k2=2,则最终字符串变为 baabcaa。
输入格式
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 l__i, r__i and k__i (1 ≤ l__i ≤ r__i ≤ |s|, 1 ≤ k__i ≤ 1 000 000) — the description of the i-th query.
输入的第一行包含字符串 s(1 ≤ ∣s∣ ≤ 10000),表示其初始状态,其中 ∣s∣ 表示 s 的长度。该字符串仅由小写英文字母组成。
第二行包含一个整数 m(1 ≤ m ≤ 300)—— 查询的个数。
接下来的 m 行中,第 i 行包含三个整数 li、ri 和 ki(1 ≤ li ≤ ri ≤ ∣s∣,1 ≤ ki ≤ 1000000)—— 描述第 i 个查询。
输出格式
Print the resulting string s after processing all m queries.
打印处理完所有 m 个查询后得到的字符串 s。
输入输出样例
输入#1
abacaba 2 3 6 1 1 4 2
输出#1
baabcaa
说明/提示
The sample is described in problem statement.
样例在题目描述中给出。
输入解题思路,AI测评打分。不知道怎么写?