QWQ
查看原帖
QWQ
1400000
Lordi楼主2024/8/16 16:49

感谢!

#include<bits/stdc++.h>
using namespace std;
string a;
int T, n, w, x;
signed main(){
	cin >> a >> T;
	n = a.size();
	while(T --){
		string b;
		cin >> b;
		if(b == "rev") ++ w, x = n - x + 1;
		if(b == "<"){
			int c;
			cin >> c;
			x = (x + n - c % n) % n;
		}
		if(b == ">"){
			int c;
			cin >> c;
			x = (x + c % n) % n;
		}
	}
	string s1, s2; 
	if(w & 1){
		s1 = a.substr(x, n - x + 1);
		s2 = a.substr(0, x);
		reverse(s1.begin(), s1.end());
		reverse(s2.begin(), s2.end());
	} else{
		s1 = a.substr(0, n - x + 1);
		s2 = a.substr(n - x + 1, x);
	}
	cout << s2 + s1;
	return 0;
}


2024/8/16 16:49
加载中...