#P2105. K皇后

K皇后

Description

Xiao Z recently found a chessboard with nn rows and mm columns. The row and column coordinates of the cells are numbered starting from 11. He wants to place KK queens on the board. He wants to know how many cells will not be attacked after he places these KK queens.

Note: A queen attacks the entire row, the entire column, and both diagonals that pass through its position.

Input Format

The first line contains three positive integers n,m,Kn,m,K, representing the number of rows and columns of the board, and the number of queens Xiao Z places.

The next KK lines each contain two positive integers x,yx,y, indicating that a queen is placed at row xx, column yy. It is guaranteed that no two queens are placed on the same cell.

Output Format

Output a single integer: the number of cells on the board that are not attacked.

12 13 6
10 4
12 10
1 1
2 3
3 2
2 6
25

Hint

  • For 30%30\% of the testdata, 1n,m5×1031\le n,m\le 5\times 10^3, 1K5001\le K\le 500.
  • For an additional 10%10\% of the testdata, K=1K=1.
  • For 100%100\% of the testdata, 1n,m2×1041\le n,m\le 2\times 10^4, 1K5001\le K\le 500.

Translated by ChatGPT 5