問題一覧 > 通常問題

No.2219 Re:010

レベル : / AI推定難易度 : 1175 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 134
作問者 : stoq / テスター : 👑 Kazun Shirotsume
お気に入りにしたユーザー ProblemId : 7698 / 自分の提出
問題文最終更新日: 2023-02-05 19:42:20
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
yukicoder contest 377 (順位表) の他の問題:

Problem Statement

For a string $X$ consisting only of '0' and '1', define $f(X)$ as the number of occurrences of $\mathsf {010}$ contained in $X$ as a subsequence (not necessarily contiguous).
Subsequences are distinguished by the positions they are taken from.

You are given a string $S$ consisting only of '0', '1', and '?'.

Replace every '?' in $S$ with '0' or '1' to create a string $S'$.
There are $2^c$ such strings $S'$, where $c$ is the number of '?' in $S$. Find the sum of $f(S')$ over all of them.

Since the answer can be very large, output it modulo $998244353$.

Input

$S$

  • $S$ is a string consisting only of '0', '1', and '?'
  • $1 \leq |S| \leq 2 \times 10^5$

Output

Output the sum of $f(S')$ over all possible $S'$, modulo $998244353$.

Sample

Sample 1
Input
01?0
Output
4

The possible strings $S'$ are $\mathsf {0100,\ 0110}$.

$f(\mathsf {0100})+f(\mathsf {0110})=2+2=4$.

Sample 2
Input
0
Output
0

The input may contain no '?', and the answer may be $0$.

Sample 3
Input
??????????
Output
15360

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。