# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 170 |
2 | Um_nik | 162 |
3 | atcoder_official | 161 |
4 | maomao90 | 160 |
5 | djm03178 | 158 |
5 | -is-this-fft- | 158 |
7 | Dominater069 | 155 |
8 | adamant | 154 |
9 | luogu_official | 153 |
10 | awoo | 152 |
Name |
---|
Suffix automaton solves this(maybe that is overkill, not sure).
You can solve it in O(NlogN) with Suffix Array + Longest Common Prefix Array. Since same substrings will be in adcajent indexes in suffix array, you can easily eliminate them. I mean first calculate the number of same substrings then substract it from (N*(N+1))/2
Actually there is a problem distinct substring (easy one link:distinct substring). I have solved it using suffix array but new substring has strict timelimit.....please suggest
O(NlogN) will work with N <= 50,000. But if you want more optimal you can get suffix array and LCP array in O(N).
thanks I will try to do it with O(n)...
I have solved both actually using java 2 years ago using suffix array and LCP. I used a faster Suffix Array construction to pass the hard one. Do you want it?
Yes i want please give me your java code and explain how u optimized it....thanks
This was my code for the easy problem
http://ideone.com/0BbVs3
The suffix array code is taken from competitive programming 3 and it gave me TLE for the hard version of the problem. So, I searched the internet for another suffix array implementation and actually I used it with the same approach.
Here is the code
http://ideone.com/kW5UFT
Thanks Safrout
Also counting the paths of a suffix automaton will solve it in linear time.