Hardcore String Counting
시간 제한8초메모리 제한2048 MB
길이 m인 소문자 문자열 가운데 주어진 패턴 s가 마지막 문자에서 처음 나타나는 문자열의 개수를 998244353으로 나눈 나머지로 구한다. n은 10^5, m은 10^9까지 주어진다.
문제
You are given a non-empty string of lowercase English letters. A string of lowercase English letters is good if every proper prefix of does not contain as a substring, but itself does.
Find the number of good strings of length . Because this number can be very large, output it modulo prime number .
입력
The first line of the input contains two integers: , the length of , and , the length of strings you have to count (, ). The second line contains a string consisting of lowercase English letters.
출력
Output a single nonnegative integer: the number of good strings of length modulo .