Night_Lord's blog

By Night_Lord, history, 3 years ago, In English

Runtime error on test 2. but I did everything as the problem statement says ...

Problem : https://codeforces.net/group/MWSDmqGsZm/contest/219856/problem/L

int n, m; cin >> n >> m;
    string s; cin >> s;
    while (m--) {
        string op; cin >> op;
        if (op == "substr") {
            int l, r; cin >> l >> r;
            l--, r--;
            cout << s.substr(l, r + 1) << '\n';
        } else if (op == "sort") {
            int l, r; cin >> l >> r;
            l--, r--;
            sort(s.begin() + l, s.begin() + r + 1);
        } else if (op == "pop_back") {
            s.pop_back();
        } else if (op == "back") {
            cout << s.back() << '\n';
        } else if (op == "reverse") {
            int l, r; cin >> l >> r;
            l--, r--;
            reverse(s.begin() + l, s.begin() + r + 1);
        } else if (op == "front") {
            cout << s.front() << '\n';
        } else if (op == "push_back") {
            char i; cin >> i;
            s.push_back(i);
        } else {
            int pos; cin >> pos;
            pos--;
            cout << s[pos] << '\n';
        }
    }
  • Vote: I like it
  • -8
  • Vote: I do not like it

| Write comment?