为何用python3如此奇怪 难顶
查看原帖
为何用python3如此奇怪 难顶
482577
lzkkk楼主2021/3/13 17:55

难顶,在本地运行都没毛病,包括测试点1的数据也没问题,一评测就re和wa。。。

def buildTree(inStr,preStr):
    rootV=preStr[0]
    str0=inStr.split(rootV)
    if len(inStr)==1:
        print(rootV,end="")
        return
    elif inStr[0]==rootV:
        buildTree(inStr[1:],preStr[1:])
        print(rootV,end="")
    elif inStr[-1]==rootV:
        buildTree(inStr[0:-1],preStr[1:])
        print(rootV,end="")
    else:
        buildTree(str0[0],preStr[1:len(str0[0])+1])
        buildTree(str0[1],preStr[len(str0[0])+1:])
        print(rootV,end="")
    return

inStr=input()
preStr=input()

buildTree(inStr,preStr)
print()
2021/3/13 17:55
加载中...