1 solutions

  • 0
    @ 2025-4-21 14:22:01
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int n,q;
    	cin>>n>>q; 
    	string s;
    	cin>>s;
    	int start=0;
    	while(q--)
    	{
    		int a,b;
    		cin>>a>>b;
    		if(a==1)
    		{
    			start-=b;
    			start+=n;//下标不能是负数
    			start%=n; 
    		}
    		else
    		{
    			int t=(start+b-1)%n;
    			cout<<s[t]<<endl;
    		}
    	}
    	return 0;
    }
    
    
    • 1

    Information

    ID
    2397
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    (None)
    # Submissions
    7
    Accepted
    2
    Uploaded By