Nộp bài | Các bài nộp | Làm tốt nhất | Về danh sách bài |
KNCB - Knights in Chessboard |
Given an m x 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 (≤ 125), denoting the number of test cases.
Each case starts with a blank line. The next line contains three integers m, n, K (1 ≤ m, n ≤ 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 ≤ x ≤ m, 1 ≤ y ≤ 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
Output for Sample Input
2
8 8 0
2 5 4
1 3
1 4
2 3
2 4
Case 1: 32
Case 2: 6
Được gửi lên bởi: | Race with time |
Ngày: | 2012-12-04 |
Thời gian chạy: | 1s-2s |
Giới hạn mã nguồn: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Ngôn ngữ cho phép: | Tất cả ngoại trừ: ASM64 GOSU PERL6 PYPY RUST SED |