No.3125 Make It Symmetry
タグ : / 解いたユーザー数 139
作問者 : 👑
Iroha_3856
Problem Statement
There is an $N \times N$ grid $A$. The cell in the $i$-th row from the top and the $j$-th column from the left is called cell $(i, j)$.
Cell $(i, j)$ of grid $A$ is painted black if $A_{i, j}$ is #, and white if it is ..
Here, a happy grid is defined as follows.
Happy grid: An $N \times N$ grid $X$ is a happy grid if (and only if) grid $X$ satisfies the following condition.
- For each $i, j ~ (1 \leq i, j \leq N)$, the color of cell $(i, j)$ of grid $X$ is equal to the color of cell $(i, N + 1 - j)$.
Also, Akane and Aoi can repeat the following operation any number of times, possibly $0$ times.
Operation: Perform the following actions in order.
- Akane chooses a cell $(i, j)$ of grid $A$ that is currently painted black.
- Aoi chooses a cell $(i', j')$ of grid $A$ that is currently painted white.
- Repaint cell $(i, j)$ of grid $A$ white and cell $(i', j')$ black.
Determine whether grid $A$ can be made into a happy grid by repeating the operation.
Constraints
- $N$ is an integer satisfying $1 \leq N \leq 500$
- $A_{i, j}$ is one of the characters
#,.
Input
The input is given from standard input in the following format.
$N$
$A_{1, 1}A_{1, 2}\ldots A_{1, N}$
$A_{2, 1}A_{2, 2}\ldots A_{2, N}$
$\vdots$
$A_{N, 1}A_{N, 2}\ldots A_{N, N}$
Output
Print Yes if grid $A$ can be made into a happy grid by repeating the operation, and No otherwise.
Sample
Sample 1
Input
3 ##. #.. ...
Output
Yes
For example, the grid can be made into a happy grid by operating as follows.
-
Akane chooses cell $(2, 1)$ and Aoi chooses cell $(1, 3)$. The grid becomes as follows, which is a happy grid.
### ... ...
Sample 2
Input
6 ...... .###.. .###.. .###.. ...... ......
Output
No
No matter how the operations are performed, the grid cannot be made into a happy grid.
Sample 3
Input
4 #..# .##. .##. #..#
Output
Yes
It is already a happy grid.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。