DWITE Online Computer Programming Contest, February 2011, Problem 2
In chess, a rook is a piece that can move to any other square on the row or column it is on. So, we say that it threatens all the squares on the row and column it is on (because it can threaten to capture any of the opponent's pieces on these squares; if there are multiple pieces in a row, the threat upon the further piece is known as skewer or an x-ray attack /chess-trivia). Given the positions of rooks on a chessboard, whose dimensions aren't necessarily
The input will contain 5 test cases. The first line of each test case contains three numbers,
The output should contain 5 lines, where each line represents the number of squares on the chessboard that are not being threatened by rooks.
Sample Input
3 3 1
2 2
8 8 3
1 1
5 5
8 8
Sample Output
4
25
Problem Resource: DWITE
Comments