def text_editor():
K = int(input())
text = input().strip()
commands = [input().strip() for _ in range(K)]
pos = 0 # 初始指针位置
for cmd in commands:
parts = cmd.split()
if not parts:
continue
op = parts[0]
if op == 'FORWARD':
X = int(parts[1])
pos = min(pos + X, len(text))
elif op == 'BACKWARD':
X = int(parts[1])
pos = max(pos - X, 0)
elif op == 'SEARCH-FORWARD':
word = ' '.join(parts[1:])
idx = text.find(word, pos)
if idx != -1:
pos = idx
elif op == 'SEARCH-BACKWARD':
word = ' '.join(parts[1:])
idx = text.rfind(word, 0, pos)
if idx != -1:
pos = idx
elif op == 'INSERT':
word = ' '.join(parts[1:])
text = text[:pos] + word + text[pos:]
pos += len(word)
elif op == 'REPLACE':
word = ' '.join(parts[1:])
if pos < len(text):
text = text[:pos] + word + text[pos + len(word):] if pos + len(word) <= len(text) else text[:pos] + word
else:
text = text[:pos] + word
pos += len(word)
elif op == 'DELETE':
X = int(parts[1])
text = text[:pos] + text[pos + X:]
pos = min(pos, len(text))
print(text)
text_editor()
1.Vscode:简称vs code,它是一个轻量且强大的代码编辑器,支持Windows,OS X和Linux。内置JavaScript、TypeScript和Node.js支持,而且拥有丰富的插件生态系统,可通过安装插件来支持C++、C#、Python、PHP等其他语言。这个也是小编最近特别喜欢的IDE。