Forethought Future Cup - Final Round (Onsite Finalists Only)
D
Palindrome XOR
Codeforces
2400
原题
← CE →
翻译中…

You are given a string $s$ consisting of characters "1", "0", and "?". The first character of $s$ is guaranteed to be "1". Let $m$ be the number of characters in $s$.

翻译中…

Count the number of ways we can choose a pair of integers $a, b$ that satisfies the following:

翻译中…
  • $1 \leq a \lt b \lt 2^m$
  • When written without leading zeros, the base-2 representations of $a$ and $b$ are both palindromes.
  • The base-2 representation of bitwise XOR of $a$ and $b$ matches the pattern $s$. We say that $t$ matches $s$ if the lengths of $t$ and $s$ are the same and for every $i$, the $i$-th character of $t$ is equal to the $i$-th character of $s$, or the $i$-th character of $s$ is "?".
翻译中…

Compute this count modulo $998244353$.

翻译中…

Input

翻译中…

The first line contains a single string $s$ ($1 \leq |s| \leq 1\,000$). $s$ consists only of characters "1", "0" and "?". It is guaranteed that the first character of $s$ is a "1".

翻译中…

Output

翻译中…

Print a single integer, the count of pairs that satisfy the conditions modulo $998244353$.

翻译中…

Note

翻译中…

For the first example, the pairs in base-2 are $(111, 10001), (11, 10101), (1001, 11111)$.

翻译中…

样例

Input #1
10110
Output #1
3
InputCopy OutputCopy
Input #2
1?0???10
Output #2
44
InputCopy OutputCopy
Input #3
1?????????????????????????????????????
Output #3
519569202
InputCopy OutputCopy
Input #4
1
Output #4
0
InputCopy OutputCopy
题目信息
题号
1147D
时间限制
1 s
内存限制
256 MB
标签
DFS 及类似
图论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。