【python】刷一个比赛的历届算法试题,结果木有给答案QwQ,请教一下各位

img


img

http://hksc.cs.cityu.edu.hk/problem/15
测试用例 (input,output)
aba,19
tpvoqwmwplmngzoutkomegqmljndrh,84804
xhbzlvoopxhtwapxtvhmtvnzbnssvv,87584

s = input()
a = set()

for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        a.add(s[i:j])

count=0
for i in a:
    for j in a:
        for k in zip(i,j):
            if k[0]==k[1]:
                count+=1
            else:
                break
print(count)

测试:

aba
19
tpvoqwmwplmngzoutkomegqmljndrh
84804
xhbzlvoopxhtwapxtvhmtvnzbnssvv
87584