当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6809:Head Maker

题目描述
Zhang3's favorite toy, Steve, has been hit and his head was broken. Zhang3 wants to make a cube as a new head for him.

Zhang3 got a piece of grid paper as material, satisfying the conditions below:

- The grid paper consists of $n \times m$ square units, forming $n$ rows by $m$ columns.
- Some units of the grid paper are broken, the others are usable.
- All of the usable units are 4-connected (two units are directly connected by sharing an edge).

By using some tools, she can do the following things for arbitrary times:

- Cut along an edge on the grid paper. After doing this, the paper mustn't be split into two pieces, i.e., all the usable units are still 4-connected.
- Fold along an edge, so that the two adjacent units form a right angle.

A cube has six faces. Every unit should overlap with one of the six faces. The paper is so thin that it's possible to overlap more than one units at the same face. But it's not allowed to leave a face without any units.

Help Zhang3 determine whether it is possible to make a cube with the grid paper.
输入解释
The first line of the input gives the number of test cases, $T \; (1 \le T \le 100)$. $T$ test cases follow.

For each test case, the first line contains two integers $n, m \; (1 \le n,m \le 6)$, the size of the grid paper.

Then $n$ lines follow, each contains a string of length $m$, describing the grid. Each character is $0$ or $1$, where $0$ means the unit is broken, and $1$ means the unit is usable.
输出解释
For each test case, print a line with a string $\text{Yes}$ or $\text{No}$, representing the answer.
输入样例
2
2 5
11111
11000
2 5
11111
01100
输出样例
No
Yes
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6809

最后修改于 2020-10-25T23:34:34+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 524288/524288K(Java/Others)