問題一覧 > 通常問題

No.883 Coloring Book

レベル : / AI推定難易度 : 1225 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 114
作問者 : QCFium / テスター : e869120
お気に入りにしたユーザー ProblemId : 3339 / 自分の提出
問題文最終更新日: 2021-01-05 14:33:19
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 223 (順位表) の他の問題:

Problem Statement

You want to create one grid whose number of rows equals its number of columns, and paint exactly $N$ of its cells black.
However, the number of black cells in any single row or column must be at most $K$.
Output the minimum number of rows of the grid, and then output which cells should actually be painted black with that number of rows.

Input

$N\ K$

$1 \le K \le N \le 1000$
$K$ and $N$ are integers

Output

Output in the following format.

$M$
$A_{1,1}A_{1,2}A_{1,3}\dots A_{1,M}$
$A_{2,1}A_{2,2}A_{2,3}\dots A_{2,M}$
$A_{3,1}A_{3,2}A_{3,3}\dots A_{3,M}$
$\hspace{7pt} \vdots \hspace{17pt} \vdots \hspace{16pt} \vdots \hspace{9pt} \ddots \hspace{8pt} \vdots$
$A_{M,1}A_{M,2}A_{M,3}\dots A_{M,M}$
$M$ represents the number of rows (= the number of columns) of the answer, and must be the minimum number of rows of a grid satisfying the conditions.
$A_{i,j}$ must be # or .; # means that the cell in row $i$ and column $j$ of the grid is black, and . means that it is not.
The total number of # must equal $N$, and the number of # in any single column or row must not exceed $K$.

Sample

Sample 1
Input
8 2
Output
4
##..
##..
..##
..##

There are other correct answers as well.

Sample 2
Input
5 1
Output
5
#....
....#
...#.
.#...
..#..

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。