codeforces 598B Queries on a String

题目链接http://codeforces.com/problemset/problem/598/B

题目分类:字符串

题意:给定一个串,然后n次旋转,每次给l,r,k,表示区间l到r的字符进行k次平移,具体移动规则看题意,求经过n次旋转之后字符串是怎样的

题目分析:自己的做法比较麻烦,后来发现别人用函数给做出来了,贴代码

代码

#include <bits/stdc++.h>
using namespace std;

int m;
char s[10013];

int main()
{
    scanf("%s",s+1);
    scanf("%d",&m);
    for (int i=0;i<m;i++)
    {
        int l,r,k;
        scanf("%d%d%d",&l,&r,&k);
        k%=(r-l+1);
        rotate(s+l,s+r+1-k,s+r+1);
    }
    printf("%s
",s+1);

    return 0;
}
anytime you feel the pain.hey,refrain.don't carry the world upon your shoulders
原文地址:https://www.cnblogs.com/gaoss/p/4970371.html