#P6972. [NEERC2016] Kids Designing Kids
[NEERC2016] Kids Designing Kids
题目描述
Kevin and Kimberly have freckles on their foreheads.
They both drew their freckle pictures on sheets of paper. Each picture is a rectangle of pixels
: every cell either has a freckle or it has no freckle.
They are jokingly proposing that when they grow up, marry, and have a child, her freckle picture is produced as a result of the following procedure:
Kevin's and Kimberly's pictures are moved by a parallel translation, and then in each cell a child has a freckle if and only if exactly one of the parents has a freckle in this position.
Now they wonder, whether there is a parallel translation that gives their child a specific freckle picture (for example, a lightning), and what is this parallel translation.
输入格式
The first line contains two integers, -- the height and the width of Kevin's freckle picture. Each of the next lines consists of characters and Character means that there is a freckle, and that there is not.
The next lines contain Kimberly's picture in the same format. Its height and width and follow the same constraints.
It is guaranteed that Kevin and Kimberly have at least one freckle each.
The next lines contain the picture they want for their child in the same format. Its dimensions and also have the same constraints.
输出格式
In the first line output YES
if the desired picture can be produced, and NO
otherwise.
If the answer is positive, then in the second line output two integers, and , with the following meaning: if you overlay the pictures so that their upper left corners coincide, then move Kimberly's picture cells right (negative number means moving picture left) and cells down (negative number means moving picture up), and then apply the procedure described above, the resulting picture can be moved by a parallel translation to coincide with the third picture from the input file.
题目大意
给定三个 01 矩阵(*
表示 ,.
表示 ),大小分别为 、 和 ,你可以将前两个矩阵的左上角重叠,然后将第二个矩阵向右平移 个长度、向下平移 个长度( 可以为负数,表示反方向)。然后将对应位置异或起来(超出部分均视为 )。
你需要判断得到的矩阵是否可能能够通过平移和第三个矩阵重合(超出部分均视为 ),并给出方案。
保证前两个矩阵都含有至少一个 。
。
3 3
..*
.*.
*.*
3 3
**.
..*
.*.
5 2
.*
*.
**
.*
*.
YES
0 2
提示
Time limit: 2 s, Memory limit: 512 MB.