Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC optimize("Ofast", "unroll-loops")
- // #pragma GCC target("avx")
- #include <bits/stdc++.h>
- using namespace std;
- #define int int64_t
- #define double __float80
- using pii = pair<int, int>;
- template <typename T> using Prior = std::priority_queue<T>;
- template <typename T> using prior = std::priority_queue<T, vector<T>, greater<T>>;
- // #define X first
- // #define Y second
- #define eb emplace_back
- #define ef emplace_front
- #define ee emplace
- #define pb pop_back
- #define pf pop_front
- #define ALL(x) begin(x), end(x)
- #define RALL(x) rbegin(x), rend(x)
- #define SZ(x) ((int)(x).size())
- #define fastIO() ios_base::sync_with_stdio(0), cin.tie(0)
- template <typename T> void _do(T &&_t) {cerr << _t << "\n";}
- template <typename T, typename ...U> void _do(T &&_t, U &&..._u) {cerr << _t << ", ", _do(_u...);}
- template <typename T, typename U> bool chmin(T &lhs, U rhs) {return lhs > rhs ? lhs = rhs, 1 : 0;}
- template <typename T, typename U> bool chmax(T &lhs, U rhs) {return lhs < rhs ? lhs = rhs, 1 : 0;}
- void solve() {
- string S; getline(cin, S);
- int C; cin >> C;
- vector<string> buf;
- for (int q = 1; q <= C; ++q) {
- string op; cin >> op;
- if (op == "COPY") {
- int L, R; cin >> L >> R, --L, --R;
- buf.eb(S.substr(L, R-L+1));
- }
- if (op == "CUT") {
- int L, R; cin >> L >> R, --L, --R;
- buf.eb(S.substr(L, R-L+1));
- S = S.substr(0, L) + S.substr(R+1);
- }
- if (op == "PASTE") {
- int pos; cin >> pos, --pos;
- S = S.substr(0, pos) + buf.back() + S.substr(pos);
- if (SZ(buf) > 1) buf.pb();
- }
- }
- cout << S << "\n";
- }
- int32_t main() {
- fastIO();
- int t = 1; // cin >> t;
- for (int _ = 1; _ <= t; ++_) {
- solve();
- }
- return 0;
- }
Advertisement
Advertisement