Educational Codeforces Round 1 B. Queries on a String(字符串简单操作)
来源:互联网 发布:淘宝外贸原单店铺推荐 编辑:程序博客网 时间:2024/06/05 04:22
题目链接
题意:给出一个字符串,再给出n个操作,每个操作是把区间[l,r]循环右移k位
解法:模拟
收获:string的substr(start,length):string的substr函数参数,表示从某一个位置起长度是length的子串,而不是表示区间[L,R]的子串,一定要注意,当然第二个参数可以省略,省略就表示到末尾。
#include<bits/stdc++.h>using namespace std;#define LL long long#define pb push_back#define X first#define Y second#define cl(a,b) memset(a,b,sizeof(a))typedef pair<int,int> P;const int maxn=10005;const int inf=1<<27;#define mod 1000000007string s;void work(int l,int r,int k){ int len=r-l+1; k%=len; string ll=s.substr(l,r-l+1-k); string rr=s.substr(r-k+1,k); //cout<<ll<<" "<<rr<<endl; s=s.substr(0,l)+rr+ll+s.substr(r+1); // cout<<"s = "<<s<<endl;}int main(){ cin>>s; //cout<<s.substr(4,1); int m;scanf("%d",&m); while(m--){ int L,R,k; scanf("%d%d%d",&L,&R,&k); work(L-1,R-1,k); } cout<<s<<endl; return 0;}
0 0
- 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
- Educational Codeforces Round 1 B.Queries on a String(模拟)
- 【Educational Codeforces Round 1B】【字符串平移 水题】Queries on a String 字符串平移水题
- Educational Codeforces Round 30(A+B)
- Educational Codeforces Round 16 B. Optimal Point on a Line
- Codeforces 598B Queries on a String 【水题】
- Codeforces 598B Queries on a String 【思维】
- [杂题] Codeforces #598B. Queries on a String
- Educational Codeforces Round 16 B. Optimal Point on a Line (水题)
- Educational Codeforces Round 16 B. Optimal Point on a Line(中位数)
- Codeforces-Educational Codeforces Round 32-(A,B,C,D)
- Educational Codeforces Round 1(B)
- Educational Codeforces Round 8 (A B C)
- Educational Codeforces Round 17 A+B
- Educational Codeforces Round 31 A B C
- Educational Codeforces Round 32 A B C
- tomcat图形化界面管理及数据源配置
- Notification相关和一些关键点收集
- 交叉验证
- PHP 计算下个月当天日期,解决跨年和2月份的各种问题
- Educational Codeforces Round 1 A. Tricky Sum(简单模拟求和)
- Educational Codeforces Round 1 B. Queries on a String(字符串简单操作)
- 关于jsp页面一些bug问题
- Educational Codeforces Round 1 D. Igor In the Museum(BFS)
- ubuntu14.04,安装Go语言(谷歌公司开发的一种语言)
- 2012-The ethical judgements
- 上线遇mybatis的大坑(错误机制)
- 个人等多个
- 学习python(一)
- 读《The Building a head thing Business When about there Are No》《创业维艰》