Chocolate and the Friends' Raid
Time limit1sMemory limit1024 MB
Given an M x N chocolate with up to 4 eaten squares, find the maximum number of 1x2 or 2x1 pieces that can be cut from the rest.
- Level
Medium5 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Coco's chocolate machine produces rectangular chocolate bars whose width and height are both multiples of 4. Coco wants to sell each bar by splitting it into or pieces. One day, () friends came over, and each of them ate one square from the bar. Find the maximum number of pieces Coco can get by splitting the remaining chocolate.
Input
The first line contains the number of test cases . The next test cases follow in order.
The first line of each test case contains , , and . is the width and is the height of the chocolate. The next lines each give the position of one square a friend ate, as the column followed by the row . The top-left cell is , and no two eaten positions are the same.
Output
For each test case, print on one line the maximum number of or pieces that can be obtained by splitting the given chocolate.
Constraints
- and are multiples of
- ,