atcoder#ABC218C. [ABC218C] Shapes
[ABC218C] Shapes
Score : points
Problem Statement
We have two figures and on a two-dimensional grid with square cells.
lies within a grid with rows and columns, and consists of the cells where is #
.
lies within the same grid with rows and columns, and consists of the cells where is #
.
Determine whether it is possible to exactly match and by -degree rotations and translations.
Constraints
- Each of and consists of
#
and.
. - Each of and contains at least one
#
.
Input
Input is given from Standard Input in the following format:
Output
Print Yes
if it is possible to exactly match and by -degree rotations and translations, and No
otherwise.
5
.....
..#..
.###.
.....
.....
.....
.....
....#
...##
....#
Yes
We can match to by rotating it -degrees counter-clockwise and translating it.
5
#####
##..#
#..##
#####
.....
#####
#..##
##..#
#####
.....
No
It is impossible to match them by -degree rotations and translations.
4
#...
..#.
..#.
....
#...
#...
..#.
....
Yes
Each of and may not be connected.
4
#...
.##.
..#.
....
##..
#...
..#.
....
No
Note that it is not allowed to rotate or translate just a part of a figure; it is only allowed to rotate or translate a whole figure.