#P3678. Unique Creative Window Patterns
Unique Creative Window Patterns
Unique Creative Window Patterns
You are given a photo of building C in Zagreb. The photo is represented by an (r \times c) grid. In the grid, windows are arranged in a regular matrix with borders. Borders are represented by the character #
and appear as complete rows (or columns) of #
. Each window is a rectangular block (not necessarily a square) whose cells are either blank (denoted by .
) or drawn (denoted by +
).
Two window patterns are considered identical if one can be rotated by (90^\circ), (180^\circ), (270^\circ), or (360^\circ) (i.e. no rotation) to exactly match the other. Note that flipping (mirroring) is not allowed. When the window is not a square, only the (0^\circ) and (180^\circ) rotations will preserve its dimensions.
Your task is to count the number of essentially different window patterns in the photo.
inputFormat
The input begins with two integers (r) and (c) (the number of rows and columns in the grid). The following (r) lines each contain a string of length (c) representing the photo. The windows are arranged in a grid, where border rows (consisting entirely of #
) separate rows of windows, and border columns (indicated by #
in the first row) separate columns of windows. All windows have the same dimensions and each window contains at least one cell.
outputFormat
Output a single integer: the number of essentially distinct window patterns found in the photo.
sample
3 3
###
#+#
###
1