C. [L2-1]生命游戏

内存限制:512 MiB 时间限制:1000 ms 标准输入输出
题目类型:传统 评测方式:Special Judge

题目描述

And God said, "The waters are to teem with teeming animal spirit; and fliers will fly over the land, upon the dome of the sky."

And God created the big sea dragons, and all the kinds of crawling beings which teemed in the water, and every winged flier to its kind, and God saw that it was good.

And God blessed them, saying: "Bear fruit and multiply, and fill the water in the seas, and birds will multiply on the land."

And it was evening, and it was morning: a fifth day.

生命游戏中, 你将出生在一个 大小的开放世界网格中, 每个网格都有一个细胞, 有存活和死亡两种状态。

虽然是开放世界,试图访问超出这 部分的网格会被提示:“前面的区域,以后再来探索吧!” 你猜为什么有Special Judge?

每经过一个时间单位, 这些细胞的状态将根据其周围的八个网格中细胞的情况, 按如下规则发生变化:

  1. 孤独: 若存活的细胞周围的存活细胞数量小于2个, 该细胞死亡.
  2. 适中: 若存活的细胞周围存活的细胞数量为2个或3个, 该细胞不会死亡.
  3. 过载: 若存活的细胞周围存活的细胞数量大于3个,该细胞死亡.
  4. 繁衍: 若死亡的细胞周围存活的细胞数量恰好为3个,该细胞复活(变为存活状态)。

某一时刻的某个细胞的存活状态,只和上一时刻有关。

现给出初始细胞存活状态, 请你输出 单位时间后的细胞状态.

输入格式

第一行三个整数 .

之后 行, 每行输入一个长度为 的 01 串, 表示初始细胞的状态, 1表示存活, 0表示死亡.

输出格式

输出 行, 每行输出一个长度为 的 01 串, 表示最终细胞的状态, 1表示存活, 0表示死亡.

样例

样例输入

5 5 2
00000
00000
01110
00000
00000

样例输出

00000
00000
01110
00000
00000

数据范围与提示