[READ-ONLY] Mirror of https://github.com/shuuji3/competitive-programming. 馃洬 Codes submitted to competitive programming platforms
aizu-online-jadge
aoj
atcoder
hackerrank
leetcode
528 B
20 lines
1s = input()
2q = int(input())
3for i in range(q):
4 line = input()
5 if 'print' in line:
6 op, a, b = line.split()
7 a = int(a)
8 b = int(b)
9 print(s[a:b+1])
10 elif 'reverse' in line:
11 op, a, b = line.split()
12 a = int(a)
13 b = int(b)
14 reversed_substring = ''.join(list(reversed(s[a:b+1])))
15 s = s[:a] + reversed_substring + s[b+1:]
16 elif 'replace' in line:
17 op, a, b, p = line.split()
18 a = int(a)
19 b = int(b)
20 s = s[:a] + p + s[b+1:]