QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 512 MB 満点: 100

#2888. Chessboard

統計

There is a chessboard with $n$ rows and $m$ columns, containing a total of $nm$ cells. Please place chess pieces in the cells (each cell can contain at most one piece) such that for all $1 \le i \le m$, the $i$-th column contains exactly $a_i$ pieces. Additionally, no two pieces on the board can be adjacent (sharing an edge).

Determine if a valid configuration exists. If it exists, output any one valid configuration.

Input

Read the data from standard input.

The first line contains two positive integers $n, m$, where $n \le 300$ and $m \le 300$.

The second line contains $m$ non-negative integers $a_1, a_2, \dots, a_m$, where $0 \le a_i \le n$.

Output

Output to standard output.

If no solution exists, output the string No.

If a solution exists, output the string Yes on the first line, followed by $n$ lines, each containing a string of length $m$, representing your constructed board configuration. Here, 0 represents an empty cell, and 1 represents a cell containing a piece.

Examples

Input 1

3 4
2 1 2 1

Output 1

Yes
1010
0101
1010

Input 2

3 4
2 3 3 3

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.