## Knights in Chessboard

View as PDF

Points: 1.48 (partial)
Time limit: 3.0s
Memory limit: 512M
Input: stdin
Output: stdout

Problem type
Allowed languages
C, C++, Go, Java, Kotlin, Pascal, PyPy, Python, Rust, Scratch

Given an ~m \times n~ chessboard where some of the cells are broken. Now you are about to place chess knights in the chessboard. You have to find the maximum number of knights that can be placed in the chessboard such that no two knights attack each other. You can't place knights in the broken cells.

Those who are not familiar with chess knights, note that a chess knight can attack eight positions in the board as shown in the picture below.

#### Input

Input starts with an integer ~T~ ~(\leq 125)~, denoting the number of test cases.

Each case starts with a blank line. The next line contains three integers ~m~, ~n~, ~K~ ~(1 \leq m~, ~n \leq 200)~. Here ~m~ and ~n~ corresponds to the number of rows and the number of columns of the board respectively. Each of the next Klines will contain two integers ~x~, ~y~ ~(1 \leq x \leq m~, ~1 \leq y \leq n)~ denoting that the ~cell(x~, ~y)~ is broken already. No broken cell will be reported more than once.

#### Output

For each case of input, print the case number and the maximum number of knights that can be placed in the board considering the above restrictions.

#### Sample Input

2
8 8 0
2 5 4
1 3
1 4
2 3
2 4


#### Sample Output

Case 1: 32
Case 2: 6