Submission #895309

# Submission time Handle Problem Language Result Execution time Memory
895309 2023-12-29T18:33:04 Z presko Collider (IZhO11_collider) C++14
0 / 100
0 ms 348 KB
#include<iostream>
#include<bits/stdc++.h>
#define MAXN 1000010
using namespace std;
int ind[MAXN];
int main()
{
    int n,q;
    string s;
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>q;
    cin>>s;
    for(int i=0;i<(int)s.size();i++)
    {
        ind[i+1]=i+1;
    }//could be skipped
    for(int i=0;i<q;i++)
    {
        char t;
        cin>>t;
        if(t=='a')
        {
            int l,r;
            cin>>l>>r;
            if(l<r)
            {
                for(int j=l+1;j<=r;j++)
                {
                    ind[j-1]=ind[j];
                }
                ind[r]=l;
            }
            else if(r<l)
            {
                for(int j=l-1;j>=r;j--)
                {
                    ind[j+1]=ind[j];
                }
                ind[r]=l;
            }
        }
        else
        {
            int pos;
            cin>>pos;
            cout<<s[ind[pos]-1]<<"\n";
        }
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -