-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrope.cpp
More file actions
48 lines (38 loc) · 928 Bytes
/
rope.cpp
File metadata and controls
48 lines (38 loc) · 928 Bytes
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
37
38
39
40
41
42
43
44
45
46
47
48
// BOJ 16994 로프와 쿼리
#include <bits/stdc++.h>
#include <ext/rope>
#define sz size()
#define bk back()
#define fi first
#define se second
using namespace std;
using namespace __gnu_cxx;
typedef long long ll;
typedef pair<int, int> pii;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string s;
int q;
cin >> s >> q;
int n = s.sz;
crope rope(s.c_str());
while (q--) {
int op;
cin >> op;
if (op == 1) {
int x, y;
cin >> x >> y;
rope = rope.substr(x, y - x + 1) + rope.substr(0, x) + rope.substr(y + 1, n);
} else if (op == 2) {
int x, y;
cin >> x >> y;
rope = rope.substr(0, x) + rope.substr(y + 1, n) + rope.substr(x, y - x + 1);
} else if (op == 3) {
int x;
cin >> x;
cout << rope[x] << '\n';
}
}
}