QOJ.ac

QOJ

Time Limit: 3.0 s Memory Limit: 512 MB Total points: 100

#18341. Absenteeism

Statistics

Bingo is a game on a square grid. Each player gets an $n \times n$ grid and writes a unique number in each cell. The game host then draws a random number, and each player looks for that number on their grid and, if the number is present on their grid, fills in the corresponding cell. This repeats until someone finds $n$ filled cells on a single line, which we will call a bingo line.

There are $2n + 2$ possible bingo lines: $n$ horizontal lines, $n$ vertical lines, and $2$ diagonal lines.

---  ...  ...  |..  .|.  ..|  \..  ../
...  ---  ...  |..  .|.  ..|  .\.  ./.
...  ...  ---  |..  .|.  ..|  ..\  /..

For example, the following grid has four bingo lines: two horizontal lines, one vertical line, and one diagonal line.

#..#.
#####
..###
#####
..###

Exactly when is a bingo line formed? That is completely random: you can get a line quite early if you are lucky, but on the other hand, you can fill most of the grid without getting any bingo lines. In this problem, we investigate the unfortunate case of filling $k$ cells without making any bingo lines.

Given two integers $n$ and $k$, determine whether it is possible to fill exactly $k$ cells in an $n \times n$ grid, without making any bingo lines. If it is possible, demonstrate how to do it.

Input

The first and only line of input contains two integers, n and k ($1 \leq n \leq 100$, $0 \leq k \leq n^2$).

Output

On the first line, output `YES` if it is possible to fill exactly k cells of an $n \times n$ grid without making any bingo lines. Otherwise, output `NO` .

If the answer is `YES` , then output $n$ rows of the grid on the next $n$ lines. Each row should be represented by a string of $n$ characters. The $i$-th character is `#` (ASCII 35) if the $i$-th cell of the row is filled, and `.` (ASCII 46) if it is not filled. Exactly $k$ cells must be filled, and there cannot be any bingo lines.

If there are multiple ways to fill the grid, then output any one of them.

Examples

Input 1

4 2

Output 1

YES
##..
....
....
....

Input 2

4 16

Output 2

NO

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.