問題一覧 > 通常問題

No.3125 Make It Symmetry

レベル : / AI推定難易度 : 550 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 139
作問者 : 👑 loop0919 / テスター : Iroha_3856 lif4635 ルク
お気に入りにしたユーザー ProblemId : 12091 / 自分の提出
問題文最終更新日: 2026-01-07 23:00:58
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 465 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。