CSU1656: Paper of FlyBrother (suffix array)

Source: Internet
Author: User
Tags bitset

CSU1656: Paper of FlyBrother (suffix array)

FlyBrother is a superman, therefore he is always busy saving the world.
To graduate from NUDT is boring but necessary for him. typically We need to post an paper to get Graduate Certificate, however being one superman, FlyBrother wants to make his paper perfect. A paper is a lower case string. to make it perfect, FlyBrother wanna the number of different substrings in the paper. it is quite a silly problem for FlyBrother, but because he is so busy, can you help him to s Olve it?



There are several cases. Process till EOF.
For each case, there is a line of lower case string (1 <= length <= 100000 ).



For each case, output one number in a line of the answer described in the problem.


Sample Input
Sample Output
Evaluate the number of different strings
Idea: I have the same questions and template questions in my suffix array question summary.
# Include
# Include
# Include
# Include
# Include
# Include
      # Include
         # Include
          # Include
           # Include
            # Include
             Using namespace std; # define LS 2 * I # define RS 2 * I + 1 # define UP (I, x, y) for (I = x; I <= y; I ++) # define DOWN (I, x, y) for (I = x; I> = y; I --) # define MEM (a, x) memset (, x, sizeof (a) # define W (a) while (a) # define gcd (a, B) _ gcd (a, B) # define LL long # define N 100005 # define MOD 1000000007 # define INF 0x3f3f3f # define EXP 1e-8www.bkjia.comLL wa [N], wb [N], wsf [N], wv [N], sa [N]; LL rank1 [N], height [N], s [N], a [N]; char str [N], str1 [N], str2 [N]; // sa: the starting position of the nth position in the Lexicographic Order in str sa [I] // rank: that is, the suffix of str I position is in the Lexicographic Order of the nth // height: the longest public prefix of the Lexicographic Order of I and the suffix of the I-1 LL cmp (LL * r, LL, LL B, LL k) {return r [a] = r [B] & r [a + k] = r [B + k];} void getsa (LL * r, LL * sa, LL n, LL m) // n should contain the 0 {LL I, j, p, * x = wa, * y = wb, * t; for (I = 0; I
              = 0; I --) sa [-- wsf [x [I] = I; p = 1; j = 1; for (; p
               = J) y [p ++] = sa [I]-j; for (I = 0; I
                = 0; I --) sa [-- wsf [wv [I] = y [I]; t = x; x = y; y = t; x [sa [0] = 0; for (p = 1, I = 1; I

Related Article

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.