Chessboard
Total Submit:12 Accepted:12
Description
Alice and Bob often play games on chessboard. One day, Alice draws a board with size M * N. She wants Bob to use a lot of cards with size 1 * 2 to cover the board. However, she thinks it too easy to bob, so she makes some holes on the board (as shown in the figure below). We call a grid, which doesn’t contain a hole, a normal grid. Bob has to follow the rules below: A VALID solution. An invalid solution, because the hole of red color is covered with a card. An invalid solution, because there exists a grid, which is not covered. Your task is to help Bob to decide whether or not the chessboard can be covered according to the rules above. 
1. Any normal grid should be covered with exactly one card.
2. One card should cover exactly 2 normal adjacent grids.
Some examples are given in the figures below:


Input
There are 3 integers in the first line: m, n, k (0 < m, n <= 32, 0 <= K < m * n), the number of rows, column and holes. In the next k lines, there is a pair of integers (x, y) in each line, which represents a hole in the y-th row, the x-th column.
Output
If the board can be covered, output "YES". Otherwise, output "NO".
Sample Input
2 1
3 3
Sample Output
Hint
A possible solution for the sample input.
Source
HHUACM
本文介绍了一种使用特定尺寸卡片覆盖带有空洞的棋盘的问题,并提供了一个算法解决方案。该问题要求所有正常网格被恰好一张卡片覆盖,且卡片必须覆盖两个相邻的正常网格。文章详细解释了输入输出格式及示例,并提供了实现这一解决方案的C++代码。
13万+

被折叠的 条评论
为什么被折叠?



