ABC205F
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Score : 600 points
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 Ai≤r≤Ci and Bi≤c≤Di.
- 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≤H,W,N≤100
- 1≤Ai≤Ci≤H
- 1≤Bi≤Di≤W
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
H W N A1 B1 C1 D1 A2 B2 C2 D2 ⋮ AN BN CN DN
Output
Print the answer.
Sample Input 1 Copy
2 3 3 1 1 2 2 1 2 2 3 1 1 1 3
Sample Output 1 Copy
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.
Sample Input 2 Copy
5 5 3 1 1 5 5 1 1 4 4 2 2 3 3
Sample Output 2 Copy
3
AGC029
- Status
- Done
- Rule
- IOI
- Problem
- 8
- Start at
- 2023-7-13 8:30
- End at
- 2023-7-13 12:00
- Duration
- 3.5 hour(s)
- Host
- Partic.
- 17