QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 128 MB مجموع النقاط: 100

#4137. Tiling a Grid

الإحصائيات

In an $N \times M$ grid, there are $K$ special cells. We want to cover this grid using a set of Tetris-like pieces such that no special cells are covered, and every non-special cell is covered by exactly one piece. Find the maximum number of pieces that can be placed.

It is known that there are three sets of pieces, and a board may use one of these sets.

Input

The first line contains three integers $N, M, K$ and a character $type$, representing the set of pieces used.

The next $K$ lines each contain two integers $X, Y$, representing that the cell at row $X$ and column $Y$ is a special cell.

Output

A single integer representing the answer.

Examples

Input 1

8 8 0 A

Output 1

32

Input 2

7 6 6 C
3 1
3 6
5 3
5 4
5 7
6 7

Output 2

12

Subtasks

Test Cases $N, M$ $K$ $type$
$1 \sim 6$ $0 < N,M \leq 100$ $0 \leq K \leq NM$ A
$7 \sim 12$ $N=M=2^L,\ 0 < L \leq 200\,000$ $K=1$ B
$13 \sim 20$ $0 < N,M \leq 11$ $0 \leq K \leq NM$ C

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.