blob: d5f5f350174e194711facf7eadc62a92a18ced2b (
plain)
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
27
28
29
30
31
32
33
34
35
36
|
#include <cstdio>
#include <string>
#include <iostream>
class Rope {
std::string s;
public:
Rope(const std::string &s) : s(s) {
}
void process( int i, int j, int k ) {
// Replace this code with a faster implementation
std::string t = s.substr(0, i) + s.substr(j + 1);
s = t.substr(0, k) + s.substr(i, j - i + 1) + t.substr(k);
}
std::string result() {
return s;
}
};
int main() {
std::ios_base::sync_with_stdio(0);
std::string s;
std::cin >> s;
Rope rope(s);
int actions;
std::cin >> actions;
for (int action_index = 0; action_index < actions; ++action_index) {
int i, j, k;
std::cin >> i >> j >> k;
rope.process(i, j, k);
}
std::cout << rope.result() << std::endl;
}
|