結果

問題 No.3370 AB → BA
コンテスト
ユーザー Aralov Otabek
提出日時 2026-01-08 23:23:29
言語 PyPy3
(7.3.17)
結果
WA  
実行時間 -
コード長 325 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 339 ms
コンパイル使用メモリ 82,212 KB
実行使用メモリ 91,136 KB
最終ジャッジ日時 2026-01-08 23:23:32
合計ジャッジ時間 2,516 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

MOD = 998244353

s = input().strip()

h = 1
segments = []
for c in s:
    if c=='B':
        h += 1
    else:
        segments.append(h)

if not segments:
    print(1)
    exit()

ans = 1
prev_h = 1
for h in segments:
    # Har bir A: oxirgi balandlikdan h gacha bo'lgan barcha variantlar
    ans = ans * h % MOD

print(ans)
0