Algorithm for SIMNUM

Can someone provide an editorial for the problem asked in this contest .
Problem link:-Similiarity number
I think the problem will be solved using LCP array but not getting any directions. Please someone help.

From the giving example it calculate repetition appearance of spesfic string or length of characters
Ababaa repeated yes length to calculated 6
Babaa repeated no length to calculated 0
Abaa repeated no length to calculated 0
Baa repeated yes length to calculated 3
Aa repeated no length to calculated 0
A repeated yes length to calculated 1
B repeated yes length to calculated 1
I think this the analysis of the given example.