CF36B.Fractal

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:64MB

AC君温馨提醒

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

题目描述

Ever since Kalevitch, a famous Berland abstractionist, heard of fractals, he made them the main topic of his canvases. Every morning the artist takes a piece of graph paper and starts with making a model of his future canvas. He takes a square as big as n × n squares and paints some of them black. Then he takes a clean square piece of paper and paints the fractal using the following algorithm:

Step 1. The paper is divided into _n_2 identical squares and some of them are painted black according to the model.

Step 2. Every square that remains white is divided into _n_2 smaller squares and some of them are painted black according to the model.

Every following step repeats step 2.

Unfortunately, this tiresome work demands too much time from the painting genius. Kalevitch has been dreaming of making the process automatic to move to making 3D or even 4D fractals.

自从著名的贝尔兰抽象派画家卡列维奇听说分形(fractals)以来,他就将分形作为了自己画布上的主要主题。每天清晨,这位艺术家都会取一张方格纸,并首先为其未来的画布制作一个模型:他取一个大小为 n×nn \times n 个方格的正方形,并将其中一些方格涂成黑色。接着,他取一张空白的正方形纸张,并按如下算法绘制分形:

步骤 1. 将这张纸划分为 n2n^2 个全等的小正方形,并依照上述模型将其中某些小正方形涂成黑色。

步骤 2. 对每一个仍保持白色的正方形,再将其划分为 n2n^2 个更小的正方形,并依照上述模型将其中某些小正方形涂成黑色。

此后每一步均重复步骤 2。

不幸的是,这项枯燥的工作耗费了这位绘画天才过多的时间。卡列维奇一直梦想着将该过程自动化,以便进一步转向创作三维甚至四维分形。

输入格式

The first line contains integers n and k (2 ≤ n ≤ 3, 1 ≤ k ≤ 5), where k is the amount of steps of the algorithm. Each of the following n lines contains n symbols that determine the model. Symbol «.» stands for a white square, whereas «*» stands for a black one. It is guaranteed that the model has at least one white square.

第一行包含两个整数 nn 和 kk(2≤n≤32 \leq n \leq 3,1≤k≤51 \leq k \leq 5),其中 kk 表示算法的步数。接下来的 nn 行中,每行包含 nn 个字符,用于描述该模型。字符 . 表示白色方格,而 * 表示黑色方格。保证该模型中至少存在一个白色方格。

输出格式

Output a matrix n__k × n__k which is what a picture should look like after k steps of the algorithm.

输出一个 nk×nkn_k \times n_k 的矩阵,该矩阵表示图片经过 kk 步算法处理后的结果。

输入输出样例

  • 输入#1

    2 3
    .*
    ..

    输出#1

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

    3 2
    .*.
    ***
    .*.

    输出#2

    .*.***.*.
    *********
    .*.***.*.
    *********
    *********
    *********
    .*.***.*.
    *********
    .*.***.*.

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

首页