当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。
定义一个串s能匹配S当且仅当s能可超出头尾得覆盖S。 如下图。

给定S,问不同的s的个数。
S的长度 < = 200000。
The only line of the standard input contains a non-empty word that is not longer than 200000 letters. It consists of small letters of English alphabet.
The first line of the standard output should contain the number of quasi-templates of word v. The second line should contain the shortest word being a quasi-template of word v . If there is more than one such shortest word, output the lexicographically smallest from the shortest quasi-templates.
aaaabaabaaaba
10 aabaa
The word from the sample input has 10 quasi-templates: aaaabaabaaab, aaaabaabaaaba, aaabaaba, aaabaabaa, aaabaabaaa, aaabaabaaaba, aabaa, aabaabaa, aabaabaaa, and abaabaaa.
| bzoj_id | 3499 |
| import_source_sha256 | a2f05e7611c357de9bccafce8697a5a9cc9024f0e96fa251e34bb6aa0597b3ba |
| bzoj_checker_pending | False |
| 时间上限 | 内存上限 |
| 10000 MS | 256 MB |