【学习笔记】【整活】SAM

· · 个人记录

Some\ Definetions

\mathbb{SAM}\ is\ a\ automatic\ machine\ that\ knows\ su\!f\!\!f\!ixs\ well

Who's\ \mathbb{SAM}?

------ \mathtt{Shrah}'s\ brother\ (bushi)

And \ he \ is \ very\ niubi! H\!e\ can\ do\ many\ things\ about\ substrings!

------ WOW!\ chess\ niubi!

\mathbb{SAM}\ is\ also\ very\ f\!ast! H\!e\ can\ get\ a\ \mathbb{DAG}\ in\ O(n)! T\!he\ \mathbb{DAG}\ knows\ every\ substrings\ f\!or\ so\ long!

How\ to\ make\ f\!rineds\ with\ \mathbb{SAM}?

W\!e\ call\ some\ sets\ endpos(\mathtt s) \mathtt s\ is\ a\ string endpos(\mathtt s)\ includes\ the\ pos\ that \ is\ an\ end\ o\!f\ \mathtt s I\!f\ endpos(\mathtt s)=endpos(\mathtt t),\ we\ call\ that\ \mathtt s\ and\ \mathtt t\ are\ in\ a\ sametype. F\!or\ example,\ we\ have\ string\ \mathrm {aaabab} endpos(\mathrm a)=\{1,2,3,5\} endpos(\mathrm {ab})= endpos(\mathrm b)=\{4,6\} endpos(\mathrm {aa})=\{2,3\} endpos(\mathrm {aaa})= \{3\} endpos(\mathrm {aaab})=endpos(\mathrm {aab})= \{4\} endpos(\mathrm {aaaba})=endpos(\mathrm {aaba})=endpos(\mathrm {aba})= \{5\} endpos(\mathrm {aaabab})= endpos(\mathrm {aabab})= endpos(\mathrm {abab})= endpos(\mathrm {bab})= \{6\} And\ we\ can\ see\ the\ sets'\ relations:\forall endpos(\mathtt s)=A,\ endpos(\mathtt t)=B,\ |\mathtt s| \geq |\mathtt t| \ \ \ there\ is\ A \cup B=\varnothing\ or A\subseteq B Prove:i\!f\ t\ is\ a\ su\!f\!\!f\!ix\ o\!f\ s,\ \forall\ k\in A,\ k\in B else ,\forall\ k\in A,\ k\notin B