Number of strings with "suffix array" not identical

Source: Internet
Author: User

Spoj after the revision is very embarrassing ...

Number of different substrings (spoj694,spoj705)
Given a string, the number of substrings is not the same.
Algorithm Analysis:
Each substring must be a prefix of a suffix, so the original problem is equivalent to asking for a non-phase between all suffixes
The number of prefixes with the same. If all suffixes follow suffix (sa[1]), suffix (sa[2]),
Suffix (sa[3]), ..., suffix (sa[n]), not difficult to find, for each new addition
In the suffix suffix (sa[k]), it will generate n-sa[k]+1 a new prefix. But there are
HEIGHT[K] is the same as the prefix of the preceding string. So suffix (sa[k]) will "contribute"
Out N-sa[k]+1-height[k] a different substring. The answer to the original question is the summation. This approach
The time complexity is O (n).

Number of strings with "suffix array" not identical

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.