エンジニア死滅シタ世界之高層ビル [MISSION LEVEL: B]-Python3

n = input()
pre=""
next_str = ""
new_str = ""
for i in range(int(n)):
    cur = input()

    if pre=="" and next_str=="":
        pre = cur #第一次
        new_str = cur
    else:
        next_str = cur  
        min_len=min(len(next_str),len(pre))
        tmp=0
        for i in range(min_len,0,-1):
            if pre[(-i):]==next_str[:i]:
                    tmp=i
                    break
        pre = pre[:len(pre)-tmp]
        new_str=pre+next_str
        pre=new_str
print(new_str)
print("\n")

你可能感兴趣的:(エンジニア死滅シタ世界之高層ビル [MISSION LEVEL: B]-Python3)