AtCoder Grand Contest 060
A
No Majority
AtCoder
⌀ 1345
原题
←B →
翻译中…

Problem Statement

翻译中…

A string $x$ consisting of lowercase English letters is said to be good if and only if the following condition is satisfied.

翻译中…
  • Every (contiguous) substring of $x$ whose length is $2$ or greater satisfies the following:
  • no character occupies the majority of that substring.
翻译中…

For example, acbca is not good because c occupies the majority of the substring cbc.

翻译中…

You are given a string $S$ of length $N$ consisting of lowercase English letters and ?. You want to replace each ? with a lowercase English letter of your choice to make $S$ a good string. Find the number of ways to make $S$ a good string, modulo $998244353$.

翻译中…

Constraints

翻译中…
  • $2 \leq N \leq 5000$
  • $S$ is a string of length $N$ consisting of lowercase English letters and ?.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N
S

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
3
a?b
Output #1
24
Every way other than `aab` and `abb` satisfies the condition.
Input #2
3
a?a
Output #2
0
Input #3
20
ugsyakganihodnwmktgi
Output #3
1
Input #4
20
??a???h?m?y?ts???tl?
Output #4
444225229
题目信息
题号
agc060_a
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。