id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

UIL2015_INVA_03_BISHOP


You’re playing chess on a nice n x m board. Your opponent decided to place k bishops around the board. How many positions do you have to safely place your pawn? In chess, a bishop moves and captures along all 4 diagonals leading away from it. It can move as much as the entire length of a diagonal to do so, therefore you are not safe anywhere along any of the diagonals leading away from a bishop.

Input
For each test case, the first three integers are, n, m, and k, where n represents the number of rows, m represents the number of columns, and k represents the number of placed bishops. The following integers are the row and column indexes of each bishop.

Output
For each test case, print the number of locations you can safely place your pawn on the board.

Constraints
1 <= t <= 10
1 <= n, m <= 1000
0 <= k <= n * m

Test Case Explanation
Examine the following test case with labels afterwards:
{2,2,2,0,0,1,0}
{n m k r c r c}
n and m are the dimensions of the board. (2 by 2)
k is the number of bishops on the board. (2)
r c r c are the row and column indexes of the bishops.
the first bishop is at 0,0 and the second is at 1,0.


UIL2015_INVA_03_BISHOP([2, 2, 1, 0, 0]) → 2
UIL2015_INVA_03_BISHOP([2, 2, 1, 1, 1]) → 2
UIL2015_INVA_03_BISHOP([2, 2, 1, 0, 1]) → 2

...Save, Compile, Run (ctrl-enter)

public int UIL2015_INVA_03_BISHOP(int[] data) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Post-solution available

Copyright Nick Parlante 2017 - privacy