№ | Пользователь | Рейтинг |
---|---|---|
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 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | Dominater069 | 154 |
8 | awoo | 154 |
10 | luogu_official | 150 |
Название |
---|
Hello,
After building suffix array and LCP array you can find |LCP| of two suffixes s and t by formula ans=min{id[s]<=k<id[t]|lcp[k]}, where id[x] is index of suffix x in suffix array. Obviously if id[s]>id[t] we should swap them. Using sparse table we can answer such queries in O(1). To solve Jarvis and LCP first build string H= S[1]+$+S[2]+#+...+S[n] (separate them by different characters). Now LCP of two strings is equal to LCP of corresponding suffixes in string H. To find how many times it occurs in all strings we can just find how many times it occurs in string H. All suffixes that have prefix equal to some string are continuous subsegment of suffix array. To find left and right bound of it we can run two binary searches to find lexicographically lowest and largest such suffix. Answer is id[highest]-id[lowest]+1.
Time complexity is O(NlogN).
I have 2 questions. 1. How would I concatenate 10000 strings with different characters? Is there some observation here that I am missing? 2. And while running binary search what would the low and high bounds be?