#BS0000146. Chia bánh thành các phần (A Piece of Cake)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Chia bánh thành các phần (A Piece of Cake)
A Piece of Cake
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
A rectangular cake has width and height , with opposite corners and . It contains strawberries at pairwise distinct integer coordinates .
The cake is cut along vertical lines and horizontal lines . Cut coordinates are strictly increasing, and no strawberry lies on a cut. The cuts create exactly rectangular pieces. Find the smallest and largest number of strawberries in any piece, including empty pieces.
Input
- The first line contains .
- The second line contains .
- Each of the next lines contains the coordinates of one strawberry.
- The next line contains , followed by a line of vertical cut coordinates .
- The next line contains , followed by a line of horizontal cut coordinates .
Output
Print two integers : the minimum and maximum numbers of strawberries in one piece.
Subtasks
- Subtask 1 (20 points): ; ; ; , ; strawberry coordinates are distinct; , ; no strawberry lies on any cut.
- Subtask 2 (30 points): ; ; ; , ; strawberry coordinates are distinct; , ; no strawberry lies on any cut.
- Subtask 3 (50 points): ; ; ; , ; strawberry coordinates are distinct; , ; no strawberry lies on any cut.
Examples
Input
7 6
5
6 1
3 1
4 2
1 5
6 2
2
2 5
2
3 4
Output
0 2
Explanation
The cuts create three columns; create three rows, giving pieces. Strawberries and share one piece, and share another, and occupies a third. Thus two pieces contain , one contains , and six contain strawberries. The answer is 0 2.