Codeforces Round 237 (Div. 2)
D
Minesweeper 1D
Codeforces
1900
原题
← CE →
翻译中…

Game "Minesweeper 1D" is played on a line of squares, the line's height is 1 square, the line's width is $*n*$ squares. Some of the squares contain bombs. If a square doesn't contain a bomb, then it contains a number from 0 to 2 — the total number of bombs in adjacent squares.

翻译中…

For example, the correct field to play looks like that: 001*2***101*. The cells that are marked with "*" contain bombs. Note that on the correct field the numbers represent the number of bombs in adjacent cells. For example, field 2* is not correct, because cell with value 2 must have two adjacent cells with bombs.

翻译中…

Valera wants to make a correct field to play "Minesweeper 1D". He has already painted a squared field with width of $*n*$ cells, put several bombs on the field and wrote numbers into some cells. Now he wonders how many ways to fill the remaining cells with bombs and numbers are there if we should get a correct field in the end.

翻译中…

Input

翻译中…

The first line contains sequence of characters without spaces $*s*_{1}*s*_{2}... *s*_{*n*}$ $(1 ≤ *n* ≤ 10^{6})$, containing only characters "*", "?" and digits "0", "1" or "2". If character $*s*_{*i*}$ equals "*", then the $*i*$-th cell of the field contains a bomb. If character $*s*_{*i*}$ equals "?", then Valera hasn't yet decided what to put in the $*i*$-th cell. Character $*s*_{*i*}$, that is equal to a digit, represents the digit written in the $*i*$-th square.

翻译中…

Output

翻译中…

Print a single integer — the number of ways Valera can fill the empty cells and get a correct field.

翻译中…

As the answer can be rather large, print it modulo $1000000007$ $(10^{9} + 7)$.

翻译中…

Note

翻译中…

In the first test sample you can get the following correct fields: 001**1, 001***, 001*2*, 001*10.

翻译中…

样例

Input #1
?01???
Output #1
4
InputCopy OutputCopy
Input #2
?
Output #2
2
InputCopy OutputCopy
Input #3
**12
Output #3
0
InputCopy OutputCopy
Input #4
1
Output #4
0
InputCopy OutputCopy
题目信息
题号
404D
时间限制
2 s
内存限制
512 MB
标签
动态规划
模拟

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