What algo?

Finally I've solved this problem using very hard optimised Main & Lorentz's algo, and 0.405s only.

But I noticed many people solved this problem very fast and using much less memory.

What algo do you use? I doubt it's possible to speed-up Main & Lorentz or Crochemore algos so much.

Is it some alternative (like suffix tree) solution, or just some strong idea can be applied to this particular problem? Is it possible to solve it in O(n)?

Re: What algo?

I use something similar with manacher algorithm with some optimization..

Re: What algo?

I use this approach:

first for every position find the answer which cover outside the string(using kmp algo) as

estimate value, and sort the estimate value in desending order, then use

bruteforce(hash+enum) to calc the answer inside the string.when estimate value <=ans break;

this program make me 0.2s AC...

Re: What algo?

Thank you, but your solution is either not very fast :)

I believe there's a strict approach exists with a strict algo for this problem.

Re: What algo?

My algorithm is similar to Shen Yang.But I also use exkmp to calc another two situaion.

Then the estimate value will become smaller.I got AC in 0.046s.

Re: What algo?

Posted by

winger 18 Apr 2024 22:03

Look up Critical Factorization Theorem