ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1842. Local Roots

What algo?
Posted by bsu.mmf.team 25 Aug 2016 18:13
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?
Posted by Shen Yang 24 Feb 2017 14:56
I use something similar with manacher algorithm with some optimization..
Re: What algo?
Posted by Shen Yang 25 Feb 2017 09:59
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?
Posted by bsu.mmf.team 13 Apr 2017 01:55
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?
Posted by Celebrate 27 Oct 2021 16:44
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.