为何全 RE
查看原帖
为何全 RE
793625
Pink_Cut_Tree楼主2024/1/14 21:03
#include<bits/stdc++.h>
using namespace std;
string s;
int n,step,x,len;
char ch;
string s2;
void rem(int x){
	while(x<0){
		x+=len;
	}
	for(int i=0;i<len;i++){
		int pos=i-x;
		while(pos<0){
			pos+=len;
		}
		while(pos>=len){
			pos-=len;
		}
		s2[i]=s[pos];
	}
	for(int i=0;i<len;i++){
		s[i]=s2[i];
	}
}
int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin>>s; 
	cin>>n;
	len=s.size();
	while(n--){
		cin>>ch;
		if(ch=='r'){
			rem(step);
			reverse(s.begin(),s.end());
			cin>>s2;
			step=0;
		}
		else{
			cin>>x;
			if(ch=='>'){
				step+=x;
			}
			else{
				step-=x;
			}
		}
	}
	rem(step);
	cout<<s;
return 0;
}
2024/1/14 21:03
加载中...