No.3370 AB → BA
レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限
: 512 MB / 標準ジャッジ問題
タグ : / 解いたユーザー数 18
作問者 :
みどりむし🦠
/ テスター :
Naru820
jupiter_68
rhoo
noya2
タグ : / 解いたユーザー数 18
作問者 :
みどりむし🦠
/ テスター :
noya2
問題文最終更新日: 2025-11-17 12:19:21
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
Problem Statement
You are given a string $S$ consisting only of A and B.
For any string $X$, you can perform the following operation:
- Choose one substring
ABcontained in $X$ and replace it withBA.
Since the answer can be very large, output it modulo $998244353$.
Constraints
- $1 \leq |S| \leq 4 \times 10^5$
- $S_i \in \{$
A,B$\} \; \scriptsize (1 \leq i \leq |S|)$
Input
The input is given from standard input in the following format:$S$
Output
Find the answer and print it modulo $998244353$ to standard output.
Sample
Sample 1
Input
BBA
Output
3
There are $3$ such strings: BBA, BAB, and ABB.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。