当前位置:网站首页>Lyndon breaks down learning notes

Lyndon breaks down learning notes

2022-06-22 11:47:00 caoyang1123

Problem - H - Codeforces

False template question ,b Stand and look jls With a call lyndon The decomposing immortal algorithm kills this problem , So I went to learn lyndon decompose , As a result, I found that after I wrote it, I just made a random data hack It fell off ( By the way b Station comments hack A wave of jls, Replied ,XD), The author may have never thought that someone would use such an unpopular algorithm ......

lyndon Decomposition means that each string , Can be uniquely divided into a series of substrings s1,s2,s3...sk, Satisfy the following two properties

1)si yes lyndon strand ,lyndon A string is defined as a string whose minimum suffix is itself , Such as ab、aab yes ,aa,ba No

2) The dictionary order of the divided substrings is monotonic ( That is, non strictly increasing ).

Such as aa It can be divided into a|a, bcbca It can be divided into bc|bc|a

Find this decomposition , If you want to be lazy , Obviously you can use the well-known suffix array , Each time, the minimum suffix position that still exists can be used as a division position ( In fact, it can also be explained by this lyndon Existence of decomposition , The uniqueness should be proved by the method of counter evidence )

But there are also special algorithms , And it is constructed recursively , Useful in some topics . Consider maintaining the last one that has been divided lyndon Decomposition end i, Currently under construction lydon Disassemble the position of the previous cycle section j, Currently under construction lyndon Decomposition end position k, And then according to j,k Dictionary order relation can deal with all kinds of situations .

The question at the top seems to work lyndon Decompose to do , Using strings border Can be divided into log The properties of a sequence of arithmetical numbers ( See jcvb String selection of ), But is jls Yes , I haven't realized , The simple way is to divide the hash into dictionary order ( look for lcp Next position ).

原网站

版权声明
本文为[caoyang1123]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206221109268698.html