QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100

#2553. 宾果

Statistics

Bingo 是一款在方格网格上进行的游戏。每位玩家获得一个 $n \times n$ 的网格,并在每个单元格中填入一个唯一的数字。游戏主持人随后随机抽取一个数字,每位玩家查看自己的网格中是否有该数字,如果有,则将对应的单元格填满。此过程重复进行,直到有人在同一行、同一列或对角线上填满了 $n$ 个单元格,我们称之为一条 bingo 线。

共有 $2n + 2$ 条可能的 bingo 线:$n$ 条水平线,$n$ 条垂直线和 $2$ 条对角线。

例如,以下网格有四条 bingo 线:两条水平线,一条垂直线和一条对角线。

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

Bingo 线究竟何时形成?这完全是随机的:如果你运气好,可能很早就形成一条线;但另一方面,你也可以在不形成任何 bingo 线的情况下填满网格的大部分。在本题中,我们研究在不形成任何 bingo 线的情况下填满 $k$ 个单元格的极端情况。

给定两个整数 $n$ 和 $k$,确定是否可以在 $n \times n$ 的网格中恰好填满 $k$ 个单元格,且不形成任何 bingo 线。如果可能,请展示一种填法。

输入格式

输入的第一行包含两个整数 $n$ 和 $k$ ($1 \le n \le 100, 0 \le k \le n^2$)。

输出格式

如果可以在不形成任何 bingo 线的情况下在 $n \times n$ 的网格中恰好填满 $k$ 个单元格,则第一行输出 “YES”。否则,输出 “NO”。

如果答案为 “YES”,则在接下来的 $n$ 行中输出网格的 $n$ 行。每一行应由一个长度为 $n$ 的字符串表示。如果该行的第 $i$ 个单元格被填满,则第 $i$ 个字符为 ‘#’ (ASCII 35),否则为 ‘.’ (ASCII 46)。必须恰好填满 $k$ 个单元格,且不能有任何 bingo 线。

如果存在多种填法,输出其中任意一种即可。

样例

样例输入 1

4 2

样例输出 1

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

样例输入 2

4 16

样例输出 2

NO

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#865EditorialOpen题解alpha10222026-01-28 02:33:07View

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.