Submission #575415

#TimeUsernameProblemLanguageResultExecution timeMemory
575415KoDCollider (IZhO11_collider)C++17
100 / 100
218 ms19452 KiB
#include <bits/extc++.h>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n, q;
    std::cin >> n >> q;
    __gnu_cxx::rope<char> r;
    while (n--) {
        char c;
        std::cin >> c;
        r.push_back(c);
    }
    while (q--) {
        char c;
        std::cin >> c;
        if (c == 'a') {
            int x, y;
            std::cin >> x >> y;
            x -= 1, y -= 1;
            const char v = r[x];
            r.erase(x, 1);
            r.insert(y, v);
        } else {
            int k;
            std::cin >> k;
            k -= 1;
            std::cout << r[k] << '\n';
        }
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...