1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| #include <iostream> #include <string> using namespace std; string s, t, op; int m, l, r; int main() { cin >> s; cin >> m; for (int i = 0; i < m; ++i) { cin >> op; if (op == "PASTE") { cin >> l; s.insert(l + 1, t); } else { cin >> l >> r; if (op == "CUT") { t = s.substr(l, r - l + 1); s.erase(s.begin() + l, s.begin() + r + 1); } else { t = s.substr(l, r - l + 1); } } cout << s << endl; } return 0; }
|