求 Hack
查看原帖
求 Hack
349824
WsW_花逝爆零人楼主2024/1/15 13:25
#include<bits/stdc++.h>
using namespace std;
string s,opt;
int n,x;
int fst;
bool rev;

void prt(){
	int i=fst;
	do{
		cout<<s[i];
		i+=(rev?-1:1);
		(i+=s.size())%=s.size();
	}while(i!=fst);
	cout<<'\n';
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>s>>n;
	while(n--){
		cin>>opt;
		if(opt[0]=='r'){
			fst+=(rev?1:-1);
			rev^=1;
		}
		else{
			cin>>x;
			(x+=1)%=s.size();
			if((opt=="<")^rev)fst-=x;
			else fst+=x;
		}
		(fst+=s.size())%=s.size();
//		prt();
	}
	prt();
	return 0;
}
2024/1/15 13:25
加载中...