Universal Cup Judging System

Universal Cup

Süre Sınırı: 2.0 s Bellek Sınırı: 1024 MB Toplam puan: 100 Hack'lenebilir ✓
İstatistikler

You are given a grid with $(3N + 1)$ rows and $(3N + 1)$ columns. Determine whether it is possible to color each cell either black or white so that all of the following conditions are satisfied. If it is possible, output one such coloring.

  • No two distinct black cells share a side.
  • Starting from any black cell, by repeatedly moving zero or more times to an adjacent black cell sharing a corner (i.e., one that is diagonally adjacent), it is possible to reach some black cell that is adjacent to the outer boundary of the grid.
  • All white cells form a single connected component; that is, for any two white cells, it is possible to move from one to the other by repeatedly moving zero or more times to an adjacent white cell sharing a side.
  • There are exactly $N + 1$ black cells in each of two specific rows, and exactly $N$ black cells in each of the remaining rows.
  • There are exactly $N + 1$ black cells in each of two specific columns, and exactly $N$ black cells in each of the remaining columns.

Input

The input is given in the following format:

N
  • All inputs are integers.
  • $1 \le N \le 500$

Output

If there is no coloring that satisfies the conditions, print No on a single line.

Otherwise, print a coloring that satisfies the conditions in the following format. Let $a_{i,j}$ denote the character representing the cell at the $i$-th row from the top and the $j$-th column from the left: each character $a_{i,j}$ should be . if the corresponding cell is white, and # if it is black.

Yes
a_{1,1}...a_{1,3N+1}
:
a_{3N+1,1}...a_{3N+1,3N+1}

If multiple valid colorings exist, any one of them will be accepted.

Example

Sample Input 1

1

Sample Output 1

No

Note

The following three output examples match the required output format for $N = 1$, but they do not satisfy the conditions and are therefore judged incorrect.

Yes
##..
#...
...#
..##
Yes
#.#.
...#
#.#.
.#..
Yes
...#
.#..
..#.
#...

In the first example, there exist black cells that share a side.

In the second example, the white cells do not form a single connected component.

In the third example, the condition on the number of black cells is not satisfied. Moreover, for example, starting from the black cell in the $2$-nd row from the top and the $2$-nd column from the left, even if you repeatedly move to black cells that share a corner, you cannot reach any black cell that is adjacent to the outer boundary of the grid.

It can be proven that when $N = 1$, no coloring satisfying the conditions exists.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1412EditorialOpen题解jianglyView

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.