在PTA平台运行时出现超时问题
from collections import deque
s = input()
index = 0
now = deque()
isRepeat = False
for x in s:
if x == '[':
index = 0
elif x == ']':
index = len(now)
elif x == '{':
if index > 0:
index -= 1
elif x == '}':
if index < len(now):
index += 1
elif x == '-':
isRepeat = not isRepeat
elif x == '=':
now.rotate(-(index-1))
now.popleft()
now.rotate(index - 1)
index -= 1
else:
if isRepeat:
now.rotate(-index)
now.popleft()
now.appendleft(x)
now.rotate(index)
else:
now.rotate(-index)
now.appendleft(x)
now.rotate(index)
index += 1
print("".join(now))
编译结果时显示有超时问题
请问有没有人能指点一下
输入样例
jilin[i lofe{{-v-} ] universiti=y
abcd[c-de
[[]][][]happy=birthday
efg[bbb}}=}}}}=[{{{{a
同问,我也是这个测试点超时