Possible to optimize?

I don’t really know a way to make this happen within the given time limit. The number of substrings is of the order of N^2. Even insertion into a Trie will exceed the time. The sum of lengths of substrings will be of the order of N^3. If it’s possible through string hashing or other advanced automata, can someone provide a way? This is the link to the problem:

@carre please help

Bhai itni coding karte ho, fir bhi 3 star hi ho :roll_eyes: :roll_eyes:


I would try with suffix array and LCP table