1 条题解

  • 0
    @ 2026-4-2 18:50:55

    //因为都是遍历,所以简化为对起始点的改变以及延伸方向

    #include <bits/stdc++.h>
    using namespace std;
    #define int long long
    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int n;
        cin>>n;
        string s;
        cin>>s;
        int start=0;
        bool sizheng=true;
        int T;
        cin>>T;
        while(T--){
            string a;
            cin>>a;
            if(a=="Eric"){
                int y=0;
                cin>>y;
                if(!sizheng){
                    start-=y;
                }
                else{
                    start+=y;
                }
            }
            else if(a=="YAO"){
                int y=0;
                cin>>y;
                if(sizheng){
                    start-=y;
                }
                else{
                    start+=y;
                }
            }
            else{
                sizheng=!sizheng;
            }
        }
        start=(start%n+n)%n;
        if(sizheng){
           for(int i=0;i<n;i++){
                 cout<<s[(i+start+s.size())%s.size()];
            } 
        }
        else{
            for(int i=n-1;i>=0;i--){
                cout<<s[(i+start+s.size())%s.size()];
            }
        }
    	return 0;
    }
    
    • 1

    信息

    ID
    19
    时间
    1000ms
    内存
    128MiB
    难度
    9
    标签
    递交数
    13
    已通过
    2
    上传者