doraemon520 @ 2024-10-23 23:09:42
n = int(input()) s = input() ls = [] for i in range(n): a = input().split() if int(a[0]) == 1: s += a[1] ls.append(s) elif int(a[0]) == 2: s = s[int(a[1]):int(a[1])+int(a[2])] ls.append(s) elif int(a[0]) == 3: s = s[:int(a[1])] + a[2] + s[int(a[1]):] ls.append(s) elif int(a[0]) == 4: if a[1] in s: for j in range(len(s)-len(a[1])): if s[j:j+len(a[1])] == a[1]: ls.append(str(j)) break else: ls.append('-1')
for i in ls: print(i)
求助
by doraemon520 @ 2024-10-23 23:10:56
n = int(input())
s = input()
ls = []
for i in range(n):
a = input().split()
if int(a[0]) == 1:
s += a[1]
ls.append(s)
elif int(a[0]) == 2:
s = s[int(a[1]):int(a[1])+int(a[2])]
ls.append(s)
elif int(a[0]) == 3:
s = s[:int(a[1])] + a[2] + s[int(a[1]):]
ls.append(s)
elif int(a[0]) == 4:
if a[1] in s:
for j in range(len(s)-len(a[1])):
if s[j:j+len(a[1])] == a[1]:
ls.append(str(j))
break
else:
ls.append('-1')
for i in ls:
print(i)