luogu#P8172. [CEOI 2021] L-triominoes

[CEOI 2021] L-triominoes

Background

Translated from CEOI 2021 Day 1 T2. L-triominoes.

Problem Description

Given an H×WH \times W rectangle, we call each smallest 1×11 \times 1 rectangle inside it a cell. Now KK 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

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 9090^\circ.

Input Format

The first line contains three non-negative integers W,H,KW, H, K, representing the number of columns, the number of rows, and the number of missing cells.

The next KK lines each contain two positive integers xi,yix_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.

4 3 3
1 1
1 3
4 3
YES
5 2 4
1 2
2 1
5 1
5 2
NO
2 3 0
YES

Hint

Sample Explanation

For sample 1, the following is a valid tiling:

capture4.PNG

For sample 2, you can never cover the cell at (1,1)(1,1).

capture5.PNG

For sample 3, the following is a valid tiling:

capture6.PNG

Subtasks

All testdata satisfy 1W131 \leq W \leq 13, 2H1092 \leq H \leq 10^9, 0K2500 \leq K \leq 250, 1xiW1 \leq x_i \leq W, and 1yiH1 \leq y_i \leq H.

Subtask ID Score Constraints
11 1010 2W132 \leq W \leq 13, 2H1032 \leq H \leq 10^3, K250K \leq 250
22 77 2W132 \leq W \leq 13, 2H1092 \leq H \leq 10^9, K=0K = 0
33 1111 2W32 \leq W \leq 3, 2H1092 \leq H \leq 10^9, K250K \leq 250
44 1717 4W64 \leq W \leq 6, 2H1092 \leq H \leq 10^9, K250K \leq 250
55 3535 7W137 \leq W \leq 13, 2H1092 \leq H \leq 10^9, K250K \leq 250
66 2020 2W132 \leq W \leq 13, 2H1092 \leq H \leq 10^9, K250K \leq 250

Translated by ChatGPT 5