coderforce 598B Queries on a String
来源:互联网 发布:python 卷积 编辑:程序博客网 时间:2024/06/06 11:46
题意:给出一个字符串(1<=长度<=10000),再给出m进行m次查询,接下来m行,每一行三个数L,r,k,L--r表示将字符串这个区间内的字符当成一个环来逆时针转 k 次,得到一个新字符串,以后每次查询修改,都是在此字符串基础上进行的。
思路:先用一个字符串临时存放(L--r)的字符,因为下标是从0开始,所以是(src[L-1]到src[r-1])位字符,再按每次查询修改k次进行修改因是环,所以位置 i --> (i+k)%(r-L+1);#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;#define LL long longconst int maxm=1e5+10;char s[maxm];char temp[maxm];int main(){ while(scanf("%s",s)!=EOF) { LL n,l,r,k; scanf("%lld",&n); for(LL i=0;i<n;i++) { LL cnt=0; scanf("%lld%lld%lld",&l,&r,&k); for(LL j=l-1;j<r;j++) { temp[j]=s[j]; } for(LL j=l-1;j<r;j++) { s[l-1+(j-l+1+k)%(r-l+1)]=temp[j]; } } printf("%s\n",s); } return 0;}
1 0
- coderforce 598B Queries on a String
- Codeforces 598B Queries on a String 【水题】
- Codeforces 598B Queries on a String 【思维】
- [杂题] Codeforces #598B. Queries on a String
- CF--B - Queries on a String
- Coderforces 598.B Queries on a String
- Educational Codeforces Round 1 B. Queries on a String
- Educational Codeforces Round 1 B. Queries on a String
- Educational Codeforces Round 1 B.Queries on a String(模拟)
- Codeforces 598B Queries on a String(rotate(begin,mid,end))
- codeforces_598B. Queries on a String
- Educational Codeforces Round 1 B. Queries on a String(字符串简单操作)
- 【Educational Codeforces Round 1B】【字符串平移 水题】Queries on a String 字符串平移水题
- coderforce 545B. Equidistant String
- codeforces - Queries on a String(模拟+取余)
- coderforce 525B. Pasha and String
- Coderforce 602B Approximating a Constant Range
- Coderforce 598A Tricky Sum
- 【C++】C++头文件
- 迭代器失效的几种情况总结
- Git pull 强制覆盖本地文件
- iOS 拨打电话的方法总结
- 排列的字典序问题
- coderforce 598B Queries on a String
- 对话框自适应大小ReSize
- 笔记九(勾股定理应用)
- gradle使用
- java 中的包装类
- 划分数
- 八数码的八重境界
- 20151116 密码文件
- CSS定位的兼容性问题