CF86B Tetris revisited

题目描述

给定一个 $n \times m$ 的游戏盘,盘内有一些格子已被填充,要求用一些图形将剩余空格填满。 可用图形都以2~5个单元格组成,包含了将2~5个单元格共边连接的所有情况,填充时可以旋转和翻转。

输入格式

第一行两个整数 $n$ 和 $m$ 。 接下来 $n$ 行,每行 $m$ 个字符,表示该行游戏盘的情况。其中"#" 代表初始填充格,"."代空格。

输出格式

如果无法用上述图形将游戏盘填满,输出 $-1$ 。 否则,输出一种填充方式,用不同的数字代表不同的图形,"#" 代表初始填充格。

说明/提示

In the third sample, there is no way to fill a cell with no empty neighbours. In the forth sample, Woll does not have to fill anything, so we should output the field from the input.