zoukankan      html  css  js  c++  java
  • 时间不够了,先保存一下

     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).

    \epsfbox{p12291.eps}

    Input 

    There will be at most 20 test cases. Each test case begins with two integers n and m ( 1$ \le$m$ \le$n$ \le$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
  • 相关阅读:
    动态规划法(八)最大子数组问题(maximum subarray problem)
    动态规划法(九)想要更多例子?
    动态规划法(五)钢条切割问题(rod cutting problem)
    MySql排序函数
    Mysql 分组函数查询
    MySql单行函数
    MySql常见的函数
    MySql常见的条件查询
    MySql的一些基础查询
    MySql资料总全
  • 原文地址:https://www.cnblogs.com/alexanderone/p/3853901.html
Copyright © 2011-2022 走看看