CF515D.Drazil and Tiles
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Drazil created a following problem about putting 1 × 2 tiles into an n × m grid:
"There is a grid with some cells that are empty and some cells that are occupied. You should use 1 × 2 tiles to cover all empty cells and no two tiles should cover each other. And you should print a solution about how to do it."
But Drazil doesn't like to write special checking program for this task. His friend, Varda advised him: "how about asking contestant only to print the solution when it exists and it is unique? Otherwise contestant may print 'Not unique' ".
Drazil found that the constraints for this task may be much larger than for the original task!
Can you solve this new problem?
Note that you should print 'Not unique' either when there exists no solution or when there exists several different solutions for the original task.
德拉齐尔提出了一个关于将 1×2 骨牌放入 n×m 网格中的问题:
“给定一个网格,其中部分格子为空,部分格子已被占据。你需要用 1×2 骨牌恰好覆盖所有空格子,且任意两块骨牌不能重叠。请输出一种可行的覆盖方案。”
但德拉齐尔并不想为该任务专门编写校验程序。他的朋友瓦尔达建议道:“何不只要求选手在解存在且唯一时才输出该解?否则选手可直接输出 ‘Not unique’。”
德拉齐尔发现,这一新任务的约束规模可能远大于原任务!
你能否解决这个新问题?
注意:当原问题无解,或存在多个不同的解时,你都应输出 ‘Not unique’。
输入格式
The first line contains two integers n and m (1 ≤ n, m ≤ 2000).
The following n lines describe the grid rows. Character '.' denotes an empty cell, and the character '*' denotes a cell that is occupied.
第一行包含两个整数 n 和 m(1≤n,m≤2000)。
接下来的 n 行描述网格的各行。字符 . 表示空单元格,字符 * 表示已被占据的单元格。
输出格式
If there is no solution or the solution is not unique, you should print the string "Not unique".
Otherwise you should print how to cover all empty cells with 1 × 2 tiles. Use characters "<>" to denote horizontal tiles and characters "^v" to denote vertical tiles. Refer to the sample test for the output format example.
如果无解或解不唯一,则应输出字符串 “Not unique”。
否则,应输出如何用 1 × 2 的骨牌覆盖所有空单元格:用字符 “<>” 表示水平放置的骨牌,用字符 “^v” 表示竖直放置的骨牌。输出格式示例参见样例测试。
输入输出样例
输入#1
3 3 ... .*. ...
输出#1
Not unique
输入#2
4 4 ..** *... *.** ....
输出#2
<>** *^<> *v** <><>
输入#3
2 4 *..* ....
输出#3
*<>* <><>
输入#4
1 1 .
输出#4
Not unique
输入#5
1 1 *
输出#5
*
说明/提示
In the first case, there are indeed two solutions:
<>^
^*v
v<>
and
^<>
v*^
<>v
so the answer is "Not unique".
在第一种情况下,确实存在两个解:
<>^
^*v
v<>
和
^<>
v*^
<>v
因此答案为“不唯一”。
输入解题思路,AI测评打分。不知道怎么写?