P10058 Reverse and Rotate求调 玄关
  • 板块灌水区
  • 楼主____QAQ____
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/8/27 15:53
  • 上次更新2024/8/27 18:43:45
查看原帖
P10058 Reverse and Rotate求调 玄关
1123756
____QAQ____楼主2024/8/27 15:53
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
string qaq;
int main(){
	cin>>s;
	int len=s.size();
	if(len==1){cout<<s;return 0;}
	qaq+=" ";qaq+=s;
	int l=1;
	cin>>n;
	bool flag=0,face;
	while(n--){
		long long x;
		string tmp;
		cin>>tmp;
		if(tmp=="rev"){
			flag=!flag;
			continue;
		}
		if(flag&&tmp==">")tmp="<";
		if(flag&&tmp=="<")tmp=">";
		if(tmp=="<"){
			cin>>x;
			l+=x; 
		}
		if(tmp==">"){
			cin>>x;
			int cnt=x-(l-1);
			l=len-cnt+1;	
		}
		l%=len;
		if(l==0)l=len;
	}
	int move,st;
	if(flag)move=-1,st=l-1;
	else move=1,st=l;
	for(int i=st;;i+=move){
		i%=len;
		if(i==0)i=len;
		cout<<qaq[i];
		if(i+move==st)break;
	} 
	return 0;
}
 
2024/8/27 15:53
加载中...