码迷,mamicode.com
首页 > 其他好文 > 详细

时间不够了,先保存一下

时间:2014-07-19 17:09:30      阅读:269      评论:0      收藏:0      [点我收藏+]

标签:des   style   http   color   os   width   

 polyomino is a plane geometric figure formed by joining one or more equal squares edge to edge.
- Wikipedia

Given a large polyomino and a small polyomino, your task is to determine whether you can compose the large one with two copies of the small one. The polyominoes can be translated, but not flipped or rotated. The two pieces should not overlap. The leftmost picture below is a correct way of composing the large polyomino, but the right two pictures are not. In the middle picture, one of the pieces was rotated. In the rightmost picture, both pieces are exactly identical, but they‘re both rotated from the original piece (shown in the lower-right part of the picture).

 

bubuko.com,布布扣

 

Input 

There will be at most 20 test cases. Each test case begins with two integers n and m ( 1bubuko.com,布布扣mbubuko.com,布布扣nbubuko.com,布布扣10) in a single line. The next n lines describe the large polyomino. Each of these lines contains exactly n characters in ` *‘,` .‘. A ` *‘ indicates an existing square, and a ` .‘ indicates an empty square. The next m lines describe the small polyomino, in the same format. These characters are guaranteed to form valid polyominoes (note that a polyomino contains at least one existing square). The input terminates with n = m = 0, which should not be processed.

 

Output 

For each case, print ` 1‘ if the corresponding composing is possible, print ` 0‘ otherwise.

 

Sample Input 

 

4 3
.**.
****
.**.
....
**.
.**
...
3 3
***
*.*
***
*..
*..
**.
4 2
****
....
....
....
*.
*.
0 0

时间不够了,先保存一下,布布扣,bubuko.com

时间不够了,先保存一下

标签:des   style   http   color   os   width   

原文地址:http://www.cnblogs.com/alexanderone/p/3853901.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!