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 | 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 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 160 |
5 | djm03178 | 158 |
5 | -is-this-fft- | 158 |
7 | adamant | 155 |
8 | Dominater069 | 154 |
9 | awoo | 152 |
9 | luogu_official | 152 |
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.