AtCoder Grand Contest 050 (Good Bye rng_58 Day 1)
翻译中…
Problem Statement
翻译中…
There is a sequence of cells that extends infinitely to both directions. You and Snuke play the following game:
翻译中…
- The judge chooses a string
$t$consisting ofBandS, called turn string, and show it to both players. - First, Snuke stands on one of the cells.
- Then, for each
$i = 1, ..., |t|$in this order, the following happens: - If the
$i$-th letter of$t$isB, it is your turn. You choose a cell that contains neither other blocks nor Snuke, and put a block on the cell. After that, if both of the two cells adjacent to Snuke's cell are blocked, you win and the game ends.- If the
$i$-th letter of$t$isS, it is Snuke's turn. He may move to an adjacent unblocked cell, or doesn't do anything.
- If the
- If the game still hasn't ended, Snuke wins and the game ends.
翻译中…
You are given a string $s$ consisting of B, S, and ?. If $s$ contains $Q$ ?s, there are $2^Q$ ways to replace each ? with B or S and get a turn string. Among those $2^Q$ strings, how many will end up with your winning, in case both players play optimally? Find the answer modulo $998,244,353$.
翻译中…
Constraints
翻译中…
$1 \leq |s| \leq 10^6$$s$consists ofB,S, and?.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
s
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
BSSBS
Output #1
0
You take the $1$st and the $4$th turn, and Snuke takes the $2$nd, the $3$rd, and the $5$th turn. In this case, if both players play optimally, it turns out that Snuke wins.
Input #2
?S?B????S????????B??????B??S??
Output #2
16777197
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。