KMP算法比较难理解,这里推荐一个视频:哔哩哔哩~阿三大神
这里推荐先去多看些别的视频以及资料啥的,注意区分一下,最长前缀后缀数组和next数组的区别(其实差不了多少,next数组是为了方便操作下标,最长前缀后缀数组全体右移1位,然后第一位赋值为-1,就是常用的next数组,全体再加1就是原始的next数组,当然你直接把最长前缀后缀数组当成next数组也行,这里分享的代码就是这样);
例题1:POJ3461
Oulipo
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 49336 | Accepted: 19597 |
Description
The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He was a member of the Oulipo group. A quote from the book:
Tout avait Pair normal, mais tout s’affirmait faux. Tout avait Fair normal, d’abord, puis surgissait l’inhumain, l’affolant. Il aurait voulu savoir où s’articulait l’association qui l’unissait au roman : stir son tapis, assaillant à tout instant son imagination, l’intuition d’un tabou, la vision d’un mal obscur, d’un quoi vacant, d’un non-dit : la vision, l’avision d’un oubli commandant tout, où s’abolissait la raison : tout avait l’air normal mais…
Perec would probably have scored high (or rather, low) in the following contest. People are