Submission #1100866

# Submission time Handle Problem Language Result Execution time Memory
1100866 2024-10-14T20:40:50 Z raphaelp Collider (IZhO11_collider) C++14
100 / 100
119 ms 3592 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;
    string S;
    cin >> S;
    vector<pair<int, int>> actions;
    for (int i = 0; i < M; i++)
    {
        char typ;
        cin >> typ;
        if (typ == 'a')
        {
            int a, b;
            cin >> a >> b;
            a--, b--;
            actions.push_back({a, b});
        }
        else
        {
            int x;
            cin >> x;
            x--;
            for (int j = actions.size() - 1; j >= 0; j--)
            {
                if (x == actions[j].second)
                    x = actions[j].first;
                else if (actions[j].second > actions[j].first && x >= actions[j].first && x < actions[j].second)
                    x++;
                else if (actions[j].second < actions[j].first && x <= actions[j].first && x > actions[j].second)
                    x--;
            }
            cout << S[x] << '\n';
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 45 ms 592 KB Output is correct
3 Correct 14 ms 592 KB Output is correct
4 Correct 27 ms 2056 KB Output is correct
5 Correct 63 ms 2276 KB Output is correct
6 Correct 82 ms 2512 KB Output is correct
7 Correct 80 ms 3592 KB Output is correct
8 Correct 27 ms 3336 KB Output is correct
9 Correct 119 ms 3592 KB Output is correct
10 Correct 61 ms 3592 KB Output is correct