sa +president_tree + brute_force Accepted this problem, seems it is O(n*poly(log(n)),but it needs some proof...,there is litte possibilaty it is O(n^2*poly(log(n))).
# | User | Rating |
---|---|---|
1 | jiangly | 3976 |
2 | tourist | 3815 |
3 | jqdai0815 | 3682 |
4 | ksun48 | 3614 |
5 | orzdevinwang | 3526 |
6 | ecnerwala | 3514 |
7 | Benq | 3482 |
8 | hos.lyric | 3382 |
9 | gamegame | 3374 |
10 | heuristica | 3357 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | -is-this-fft- | 166 |
3 | Um_nik | 161 |
3 | atcoder_official | 161 |
5 | djm03178 | 157 |
6 | Dominater069 | 156 |
7 | adamant | 154 |
8 | luogu_official | 152 |
9 | awoo | 151 |
10 | TheScrasse | 147 |
sa +president_tree + brute_force Accepted this problem, seems it is O(n*poly(log(n)),but it needs some proof...,there is litte possibilaty it is O(n^2*poly(log(n))).
Name |
---|
president_tree ?? I`m missed smth definitely interesting.
My approach is very brute_force,and it is an online algorithm:
First build suffix array and lcp[], for each query [li,ri],lets find the nearest right rank of position (lm=li), in the position,interval [li+1,ri],we denote this positon,pos,then find lcp=lcp[li][pos], then lm=max(pos, ri-lcp+1), in order to speed up to find the first yes postion, we must deal with parttern str=AAAAAAAA+prefix(A) (this is not legal answer,but currenc lcp value is max.),A is a string,if this pattern is occur we directly get pos=max(pos,len(str)-len(A))..
with this speed up we can get the first yes positon (pos+lcp>ri) we only jump log(n) times, but this is not the final answer, this is a lcp_max() answer but not the left most answer, so we must continue to go left, denote lm=max(lm,ri-lcp+1),rm=min(rm,sa[pos]-1), similarly there may occur str=AAAAAAA+prefix(A) (this is a legal answer), we can binary_search to find the left most legal answer (jump lenth(A) positon),and denote rm with this left most legal postion.
this is an online algorithm and I have test for each query the maximum iteration times is not exceed 40, so maybe this is an O(q*Log(n)^log(n)) algorithm...
and seems editorial is an offline parralell binary search approach, this is interesting.