CF36B.Fractal

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

注意这题要加上这个:

freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);

输入格式

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×nn×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 n2n^{2} identical squares and some of them are painted black according to the model.

Step 2. Every square that remains white is divided into n2n^{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.

输出格式

The first line contains integers nn and kk ( 2<=n<=32<=n<=3 , 1<=k<=51<=k<=5 ), where kk is the amount of steps of the algorithm. Each of the following nn lines contains nn 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.

输入输出样例

  • 输入#1

    2 3
    .*
    ..
    

    输出#1

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

    3 2
    .*.
    ***
    .*.
    

    输出#2

    .*.***.*.
    *********
    .*.***.*.
    *********
    *********
    *********
    .*.***.*.
    *********
    .*.***.*.
    
首页