{"blog_url":"https://qnighy.hatenablog.com/","provider_name":"Hatena Blog","height":"190","image_url":null,"title":"KMP\u6cd5\u306e\u304a\u52c9\u5f37","author_name":"qnighy","published":"2010-01-17 22:26:24","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fqnighy.hatenablog.com%2Fentry%2F20100117%2F1263734784\" title=\"KMP\u6cd5\u306e\u304a\u52c9\u5f37 - \u7c21\u6f54\u306aQ\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","type":"rich","author_url":"https://blog.hatena.ne.jp/qnighy/","categories":["Programming","C++"],"version":"1.0","description":"\u3060\u304c\u89e3\u8aac\u306f\u9762\u5012\u306a\u306e\u3067\u3057\u306a\u3044\u3002 maketable\u3055\u3048\u899a\u3048\u308c\u3070search\u306f\u305d\u308c\u3068\u5f62\u304c\u4f3c\u3066\u3044\u308b\u306e\u3067\u7c21\u5358\u305d\u3046\u3002 #include <cstdio> void kmp_maketable(const char *key, int *table) { table[0]=-1;table[1]=0; int i=2,j=0; while(i==0 || key[i-1]) { if(key[i-1] == key[j]) { table[i++] = ++j; } else if(j>0) { j = table[j]; } else { table[i++] = 0; } } } void simpl\u2026","width":"100%","url":"https://qnighy.hatenablog.com/entry/20100117/1263734784","provider_url":"https://hatena.blog","blog_title":"\u7c21\u6f54\u306aQ"}