#P1924. Maximum Poster Placement on a Wall with Holes

    ID: 15206 Type: Default 1000ms 256MiB

Maximum Poster Placement on a Wall with Holes

Maximum Poster Placement on a Wall with Holes

You are given a wall of size (n \times m). Some cells on the wall contain holes. A poster is a rectangle of size (2 \times 3) (or (3 \times 2) when rotated) that must be placed with its edges parallel to the wall's borders. The poster cannot cover any cell with a hole. Determine the maximum number of posters that can be placed on the wall without overlapping (i.e. no cell is covered by more than one poster).

Note: The poster can be placed in either orientation: horizontal (covering 2 rows and 3 columns) or vertical (covering 3 rows and 2 columns).

inputFormat

The input consists of multiple lines. The first line contains two integers (n) and (m) denoting the dimensions of the wall. The second line contains an integer (k), the number of holes. Each of the following (k) lines contains two integers (r) and (c), indicating the position (row and column) of a hole. The rows and columns are 1-indexed.

outputFormat

Output a single integer representing the maximum number of posters that can be placed on the wall.

sample

3 3
0
1

</p>