P8172 [CEOI 2021] L-triominoes

Background

Translated from CEOI 2021 Day 1 T2. [L-triominoes](https://hsin.hr/ceoi/competition/ceoi2021_day1_tasks.pdf).

Description

Given an $H \times W$ rectangle, we call each smallest $1 \times 1$ rectangle inside it a cell. Now $K$ cells of this rectangle are missing. Determine whether it is possible to completely cover the whole rectangle using tiles of the shape shown below. ![capture3.PNG](https://cdn.luogu.com.cn/upload/image_hosting/ylltjsyr.png) We say a rectangle can be covered if and only if all non-missing cells are each covered by exactly one tile, and no tile goes outside the rectangle or covers any missing cell. Of course, the tiles may also be rotated vertically or by $90^\circ$.

Input Format

The first line contains three non-negative integers $W, H, K$, representing the number of columns, the number of rows, and the number of missing cells. The next $K$ lines each contain two positive integers $x_i, y_i$, describing the coordinates of a missing cell. It is guaranteed that all given cell coordinates are distinct.

Output Format

If it is possible to cover the rectangle exactly, output one line with the string `YES`. Otherwise, output one line with the string `NO`.

Explanation/Hint

#### Sample Explanation For sample 1, the following is a valid tiling: ![capture4.PNG](https://cdn.luogu.com.cn/upload/image_hosting/xgj9bfbw.png) For sample 2, you can never cover the cell at $(1,1)$. ![capture5.PNG](https://cdn.luogu.com.cn/upload/image_hosting/hrrzvyjx.png) For sample 3, the following is a valid tiling: ![capture6.PNG](https://cdn.luogu.com.cn/upload/image_hosting/p5awynm4.png) #### Subtasks All testdata satisfy $1 \leq W \leq 13$, $2 \leq H \leq 10^9$, $0 \leq K \leq 250$, $1 \leq x_i \leq W$, and $1 \leq y_i \leq H$. | Subtask ID | Score | Constraints | | :--------: | :---: | :---------: | | $1$ | $10$ | $2 \leq W \leq 13$, $2 \leq H \leq 10^3$, $K \leq 250$ | | $2$ | $7$ | $2 \leq W \leq 13$, $2 \leq H \leq 10^9$, $K = 0$ | | $3$ | $11$ | $2 \leq W \leq 3$, $2 \leq H \leq 10^9$, $K \leq 250$ | | $4$ | $17$ | $4 \leq W \leq 6$, $2 \leq H \leq 10^9$, $K \leq 250$ | | $5$ | $35$ | $7 \leq W \leq 13$, $2 \leq H \leq 10^9$, $K \leq 250$ | | $6$ | $20$ | $2 \leq W \leq 13$, $2 \leq H \leq 10^9$, $K \leq 250$ | Translated by ChatGPT 5