#abc215e. E - Chain Contestant
E - Chain Contestant
Score : points
问题描述
在另一个世界中的AtCoder举办了10种类型的竞赛,分别为AAC、...、AJC。从现在开始将会有N场竞赛。 这N场竞赛的类型以字符串S的形式给出:如果S的第i个字符是x,则第i场竞赛为AxC。
AtCoDeer将会从这N场竞赛中选择并参加一场或多场比赛,以满足以下条件:
- 在他所参加的所有比赛序列中,相同类型的竞赛必须是连续的。
- 形式上,当AtCoDeer参加x场竞赛且其中第i场竞赛的类型为T_i时,对于所有满足的整数三元组,若,则必须有。
请你求出AtCoDeer选择参加比赛的方式数量,并对998244353取模。 两种选择比赛的方式被认为是不同的,当存在一场竞赛c,使得AtCoDeer在一种方式下参加了c,而在另一种方式下没有参加c。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
AtCoder in another world holds types of contests called AAC, ..., AJC. There will be contests from now on.
The types of these contests are given to you as a string : if the -th character of is , the -th contest will be AC.
AtCoDeer will choose and participate in one or more contests from the so that the following condition is satisfied.
- In the sequence of contests he will participate in, the contests of the same type are consecutive.
- Formally, when AtCoDeer participates in contests and the -th of them is of type , for every triple of integers such that , must hold if .
Find the number of ways for AtCoDeer to choose contests to participate in, modulo .
Two ways to choose contests are considered different when there is a contest such that AtCoDeer participates in in one way but not in the other.
Constraints
- consists of uppercase English letters from
A
throughJ
.
Input
Input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
4
BGBH
Sample Output 1
13
For example, participating in the -st and -rd contests is valid, and so is participating in the -nd and -th contests.
On the other hand, participating in the -st, -nd, -rd, and -th contests is invalid, since the participations in ABCs are not consecutive, violating the condition for the triple .
Additionally, it is not allowed to participate in zero contests.
In total, there are valid ways to participate in some contests.
Sample Input 2
100
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBIEIJEIJIJCGCCFGIEBIHFCGFBFAEJIEJAJJHHEBBBJJJGJJJCCCBAAADCEHIIFEHHBGF
Sample Output 2
330219020
Be sure to find the count modulo .
update @ 2024/3/10 09:33:08