60pts,大佬求调 玄关
查看原帖
60pts,大佬求调 玄关
1038826
wusixuan楼主2024/1/15 19:20
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	string S;
	int n;
	cin >> S;
	cin >> n;
	string op;
	int x;
	int cnt=0;
	bool f=0;
	for (int i = 0; i < n; ++i) {
		cin >> op;
		if (op == "rev") {
			f=!f;
		} else {
			cin >> x;
			x%=S.size();
			if (op[0] == '<') {
				if(f==1) cnt-=x;
				else cnt+=x;
			} else if (op[0] == '>') {
				if(f==1) cnt+=x;
				else cnt-=x;
			}
		}
	}
	cnt=cnt%(S.size());
	if(f) reverse(S.begin(),S.end());
	string 	s=S;s+=s;
	cout<<s.substr(cnt,S.size());
	return 0;
}

2024/1/15 19:20
加载中...