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 1590. Bacon’s Cipher

A simple solution using suffix arrays
Posted by 吕蒙子明 22 Apr 2011 00:07
Well, the N is rather small that we can construct the suffix array for O(N^2logN)
for example, we get all the suffix and sort it:
a
aa
aaa

then calculate the longest common prefix(LCP) between two neighbour string
we get :
1
2
it means that: the substring "a" occurs 3 times (in string 1,2, LCP is "a",in string 2,3, LCP is "aa", which also contains "a") , and should be counted as once
the substring "aa" occurs twice and it's also should be counted as once
then the answer should be : 3 * (3 + 1) / 2 - 1 - 2 = 3
Re: A simple solution using suffix arrays
Posted by ASK 7 Feb 2014 00:15
https://sites.google.com/site/yuta256/sais
is a good implementation of the suffix array
Re: A simple solution using suffix arrays
Posted by akos tajti 20 Jun 2014 20:54
i found the DC3 algorithm much easier to understand (and implement). and it is fast enough (even in scala)