AtCoder Beginner Contest 285
G
Tatami
AtCoder
⌀ 2566
原题
← Ex→
翻译中…

Problem Statement

翻译中…

We have a grid with $H$ horizontal rows and $W$ vertical columns. We denote by square $(i,j)$ the square at the $i$-th row from the top and $j$-th column from the left.

翻译中…

We want to cover this grid with $1 \times 1$ tiles and $1 \times 2$ tiles so that no tiles overlap and everywhere is covered by a tile. (A tile can be rotated.)

翻译中…

Each square has 1, 2, or ? written on it. The character written on square $(i, j)$ is $c_{i,j}$. A square with 1 written on it must be covered by a $1 \times 1$ tile, and a square with 2 by a $1 \times 2$ tile. A square with ? may be covered by any kind of tile.

翻译中…

Determine if there is such a placement of tiles.

翻译中…

Constraints

翻译中…
  • $1 \leq H,W \leq 300$
  • $H$ and $W$ are integers.
  • $c_{i,j}$ is one of 1, 2, and ?.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

H W
c_{1,1}c_{1,2}\ldots c_{1,W}
\vdots
c_{H,1}c_{H,2}\ldots c_{H,W}

翻译中…

Output

翻译中…

Print Yes if there is a placement of tiles to satisfy the conditions in the Problem Statement; print No otherwise.

翻译中…

样例

Input #1
3 4
2221
?1??
2?21
Output #1
Yes
For example, the following placement satisfies the conditions. ![image](https://img.atcoder.jp/abc285/d984ec33355bac05ecebc41076d9a8df.png)
Input #2
3 4
2?21
??1?
2?21
Output #2
No
There is no placement that satisfies the conditions.
Input #3
5 5
11111
11111
11211
11111
11111
Output #3
No
题目信息
题号
abc285_g
时间限制
3 s
内存限制
1024 MB

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