QOJ.ac

QOJ

実行時間制限: 8 s メモリ制限: 512 MB 満点: 100

#2275. L-三格骨牌

統計

Luka 偶然发现了一个高为 $H$、宽为 $W$ 的矩形棋盘,它被划分为 $W \times H$ 个单位正方形。他很快注意到,其中恰好有 $K$ 个单位正方形缺失。

有趣的是,Luka 刚好有无穷多个 L 型三格骨牌(L-triominoes)。是否可以使用这些骨牌铺满给定的棋盘?

如果棋盘上的每个单位正方形都被骨牌的一个方格覆盖,我们就认为棋盘被正确铺满了。此外,骨牌不能覆盖任何缺失的正方形,且不能重叠或超出棋盘边界。当然,骨牌可以绕任意角度旋转 90 度的倍数。

输入格式

第一行包含三个整数 $W$、$H$ 和 $K$ ($0 \le K \le W \cdot H$)。

接下来的 $K$ 行中,第 $i$ 行包含两个整数 $x_i$ ($1 \le x_i \le W$) 和 $y_i$ ($1 \le y_i \le H$),表示第 $i$ 个缺失正方形的坐标。给定的缺失正方形互不相同。

输出格式

如果 Luka 可以成功铺满给定的棋盘,输出 "YES";否则,输出 "NO"。

子任务

子任务 分值 数据范围
1 10 $2 \le W \le 13, 2 \le H \le 1\,000, K \le 250$
2 7 $2 \le W \le 13, 2 \le H \le 10^9, K = 0$
3 11 $2 \le W \le 3, 2 \le H \le 10^9, K \le 250$
4 17 $4 \le W \le 6, 2 \le H \le 10^9, K \le 250$
5 35 $7 \le W \le 13, 2 \le H \le 10^9, K \le 250$
6 20 $2 \le W \le 13, 2 \le H \le 10^9, K \le 250$

样例

输入 1

4 3 3
1 1
1 3
4 3

输出 1

YES

说明 1

输入 2

5 2 4
1 2
2 1
5 1
5 2

输出 2

NO

说明 2

Luka 无法放置一个有效的骨牌来覆盖正方形 $(1, 1)$。

输入 3

2 3 0

输出 3

YES

说明 3

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.