LOJ6031 "Yali training 2017 Day1" string SAM, root partition

Portal


Notice \ (QK \ Leq 10 ^ 5 \) , we areDo notNaturally consider root partition:

When \ (K> \ sqrt {10}. 5 ^ \) , this time \ (Q \) is relatively small, and \ (QM \) correlation algorithm more suitable. Of the string \ (S \) to build the SAM, consider each interrogation, to all \ ((a, b) \ ) according to \ (B \) from small to large, then \ (W \) in \ (S \) matches the SAM, whenever the right point becomes \ (B \) when multiplying jump string \ (s [a: b] \) a location query to endpos.

When \ (Q> \ sqrt {10}. 5 ^ \) , this time \ (K \) is relatively small, and \ (k ^ 2 \) correlation algorithm more suitable. Similarly to the string \ (S \) built SAM, enumeration left endpoint \ (L \) then \ (w [l:] \ ) in all of the calculated matching SAM \ ((l, r) \ ) answers then for all () \ (l, r) \ -half of the current inquiry determined how many of the current inquiry, you can get an answer.

Complexity \ (O (m \ sqrt {logN QK}) \) . A magical thing is the block size \ (316 \) to make life difficult but \ (315 \) can too.

code

Guess you like

Origin www.cnblogs.com/Itst/p/11520011.html