Cod sursa(job #2906847)

Utilizator redstonegamer22Andrei Ion redstonegamer22 Data 27 mai 2022 16:45:27
Problema Secv8 Scor 25
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.89 kb
#include <bits/stdc++.h>
#include <ext/rope>

using namespace std;
using vec = __gnu_cxx::rope<int>;

#ifndef LOCAL
ifstream in("secv8.in");
ofstream out("secv8.out");
#define cin in
#define cout out
#endif // LOCAL

int main() {
    int q; cin >> q;
    { string _unused; cin >> _unused; assert(_unused == "0"); }

    vec v;

    while(q--) {
        char ch; cin >> ch;

        if(ch == 'I') {
            int x, n; cin >> x >> n;
            v.insert(x - 1, n);
        }
        if(ch == 'A') {
            int x; cin >> x;
            cout << v[x - 1] << '\n';
        }
        if(ch == 'D') {
            int x, y; cin >> x >> y;
            v.erase(x - 1, y - x + 1);
        }
        if(ch == 'R') {
            int _x, _y; cin >> _x >> _y;
        }

        // for(auto e : v) cerr << e << " "; cerr << endl;
    }

    for(auto e : v) cout << e << " ";
}