CF534F.Simplified Nonogram

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In this task you have to write a program dealing with nonograms on fields no larger than 5 × 20.

Simplified nonogram is a task where you have to build such field (each cell is either white or black) that satisfies the given information about rows and columns. For each row and each column the number of contiguous black segments is specified.

For example if size of the field is n = 3, m = 5, аnd numbers of contiguous black segments in rows are: [2, 3, 2] and in columns are: [1, 0, 1, 2, 1] then the solution may look like:

It is guaranteed that on each test in the testset there exists at least one solution.

本题要求你编写一个程序,用于求解尺寸不超过 5×205 \times 20 的非ogram(诺诺格)谜题。

简化版非ogram是一种逻辑谜题:你需要构造一个由黑白两色单元格组成的网格(每个格子为白色或黑色),使其满足给定的关于各行与各列的约束条件。对每一行和每一列,均给出其连续黑色段的数量。

例如,若网格尺寸为 n=3, m=5n = 3,\ m = 5,各行的连续黑色段数量分别为 [2, 3, 2][2,\ 3,\ 2],各列的连续黑色段数量分别为 [1, 0, 1, 2, 1][1,\ 0,\ 1,\ 2,\ 1],则一个可能的解如下所示:

保证测试集中每个测试用例至少存在一个合法解。

输入格式

In the first line there follow two integers n, m (1 ≤ n ≤ 5, 1 ≤ m ≤ 20) — number of rows and number of columns respectively.

Second line contains n integers _a_1, _a_2, ..., a__n where a__i is the number of contiguous black segments in i-th row of the field.

Similarly, third line contains m integers _b_1, _b_2, ..., b__m where b__i is the number of contiguous black segments in the i-th column of the field.

It is guaranteed that there exists at least one solution.

第一行包含两个整数 nn、mm(1 ≤ n ≤ 51 ≤ n ≤ 5,1 ≤ m ≤ 201 ≤ m ≤ 20),分别表示网格的行数和列数。

第二行包含 nn 个整数 a1, a2, ..., ana_1, a_2, ..., a_n,其中 aia_i 表示网格第 ii 行中连续黑色段的数量。

类似地,第三行包含 mm 个整数 b1, b2, ..., bmb_1, b_2, ..., b_m,其中 bib_i 表示网格第 ii 列中连续黑色段的数量。

保证至少存在一个解。

输出格式

Output any possible solution. Output should consist of n lines each containing m characters. Denote white cell as "." and black cell as "*".

输出任意一种可能的解。输出应包含 n 行,每行包含 m 个字符。用 “.” 表示白色格子,用 “*” 表示黑色格子。

输入输出样例

  • 输入#1

    3 5
    2 3 2
    1 0 1 2 1

    输出#1

    *.**.
    *.*.*
    *..**
  • 输入#2

    3 3
    2 1 2
    2 1 2

    输出#2

    *.*
    .*.
    *.*
  • 输入#3

    3 3
    1 0 1
    2 2 2

    输出#3

    ***
    ...
    ***

输入解题思路,AI测评打分。不知道怎么写?

首页