길이 10^6 이하의 문자열에서 서로 엄격히 포함되는 회문 부분문자열의 중첩 수열 개수를 998244353으로 나눈 나머지를 구한다.
어려움9문자열동적 계획법문자열 매칭조합론아직 제출이 없습니다시간 제한2초메모리 제한512 MBGiven a string A of length n. Consider palindromic substrings of this string. Each palindromic substring is defined by its starting position s and its end e (1≤s≤e≤n) such that letters in A starting at position s and ending at position e, inclusive, form a palindrome (i.e. A\[s+i]=A\[e−i] for any integer i between 0 and e−s, inclusive).
Let's define an embedding of depth k≥1 as a sequence of k palindromic substrings of A with the following property: s_1<…<s_k and e_1>…>e_k, i.e. palindromes in the embedding are strictly contained in each other like the Russian dolls.
Given A, count the number of possible embeddings. Since this number can be too large, calculate it modulo 998,244,353.
The input consists of a single line containing the string A. The string is non-empty and consists of no more than 106 lowercase English letters.
Print the number of possible embeddings modulo 998,244,353.
For the sample input 1, we have nine embeddings of depth 1 (1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 2-4, 4-6, 1-5), six embeddings of depth 2 (3-3 in 2-4, 5-5 in 4-6, 2-2 in 1-5, 3-3 in 1-5, 4-4 in 1-5, 2-4 in 1-5), and one embedding of depth 3 (3-3 in 2-4 in 1-5), with 9+6+1=16 embeddings in total.