#P7942. Lily White's k-CON String Substrings
Lily White's k-CON String Substrings
Lily White's k-CON String Substrings
Lily White is playing with strings. She likes strings that contain only one kind of letter, and she calls a string of length (x) an "(x)-CON string". For example, (qqqq) is a (4)-CON string, while (aaab) is not a CON string.
She has composed an array (a) of (n) strings, each of length (m), to herald the coming of spring. It is guaranteed that every string in (a) contains at least two different letters. For each permutation (p = {p_1, p_2, \dots, p_n}) of ({1,2,\dots,n}), Lily concatenates the strings in the order (a_{p_1}, a_{p_2}, \dots, a_{p_n}) to form a string (s) of length (nm).
She is fond of (k)-CON strings, meaning substrings of length (k) that are composed of a single repeated character. Your task is to compute, over all (n!) permutations, the sum of the number of non-empty substrings of (s) that are (k)-CON strings. Since the answer may be enormous, output it modulo (998244353).
inputFormat
The first line contains three integers (n), (m), and (k), separated by spaces. Each of the next (n) lines contains a string of length (m) consisting of lowercase letters. It is guaranteed that every string contains at least two different letters.
outputFormat
Output a single integer — the sum of the counts of (k)-CON substrings (substrings of length (k) composed of identical letters) over all non-empty substrings of (s) across all (n!) permutations of the array (a), taken modulo (998244353).
sample
2 3 2
aba
cbc
0