AtCoder Beginner Contest 205
F
Grid and Tokens
AtCoder
⌀ 2088
原题
← E→
翻译中…

Problem Statement

翻译中…

There is a grid with $H$ rows and $W$ columns. Let $(r, c)$ denote the square at the $r$-th row from the top and $c$-th column from the left.

翻译中…

We have $N$ pieces. For the $i$-th piece, we can choose to do one of the following:

翻译中…
  • Put it at a square $(r, c)$ such that $A_i \leq r \leq C_i$ and $B_i \leq c \leq D_i$.
  • Do not put it on the grid.
翻译中…

However, we cannot put two pieces in the same row or the same column.

翻译中…

At most how many pieces can we put on the grid?

翻译中…

Constraints

翻译中…
  • $1 \leq H, W, N \leq 100$
  • $1 \leq A_i \leq C_i \leq H$
  • $1 \leq B_i \leq D_i \leq W$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

H W N
A_1 B_1 C_1 D_1
A_2 B_2 C_2 D_2
\vdots
A_N B_N C_N D_N

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
2 3 3
1 1 2 2
1 2 2 3
1 1 1 3
Output #1
2
By putting the first piece at $(1, 1)$, the second piece at $(2, 2)$, and not putting the third piece on the grid, we can put two pieces on the grid. We cannot put three, so we should print $2$.
Input #2
5 5 3
1 1 5 5
1 1 4 4
2 2 3 3
Output #2
3
题目信息
题号
abc205_f
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。