-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuva12538.cpp
More file actions
46 lines (43 loc) · 889 Bytes
/
uva12538.cpp
File metadata and controls
46 lines (43 loc) · 889 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
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <ext/rope>
using namespace std;
using namespace __gnu_cxx;
int n;
char s[10007];
crope ver[50007], now;
int main() {
int d = 0, v = 0, p = 0, nowv = 0, c = 0;
while (1 == scanf("%d", &n)) {
for (int i = 1; i <= n; ++i) {
int typ;
scanf("%d", &typ);
now = ver[nowv];
if(typ == 1) {
scanf("%d%s", &p, s);
p -= d;
now.insert(p, s);
ver[++nowv] = now;
} else if(typ == 2) {
scanf("%d%d", &p, &c);
p -= d, c -= d;
now.erase(p - 1, c);
ver[++nowv] = now;
} else {
scanf("%d%d%d", &v, &p, &c);
v -= d, p -= d, c -= d;
crope cur = ver[v].substr(p - 1, c);
int len = cur.size();
int cnt = 0;
for (int j = 0; j < len; ++j) {
if (cur[j] == 'c') ++cnt;
}
d += cnt;
printf("%s\n", cur.c_str());
}
}
}
return 0;
}