#include #include using namespace std; int main() { int x, y, n, qx, qy, _x, _y; char **chessboard = new char*[20000]; for(int i = 0; i < 20000; i++) chessboard[i] = new char[20000]; // while(1) { scanf("%d %d %d", &x, &y, &n); if(x == 0 && y == 0 && n == 0) break; // int result = x * y; for(int i = 0; i < x; i++) for(int j = 0; j < y; j++) chessboard[i][j] = 0; // for(int queens = 0; queens < n; queens++) { scanf("%d %d", &qx, &qy); qx -= 1; qy -= 1; // for(int i = 0; i < x; i++) // X { if(chessboard[i][qy] == 0) { chessboard[i][qy] = 1; result--; } } for(int i = 0; i < y; i++) // Y { if(chessboard[qx][i] == 0) { chessboard[qx][i] = 1; result--; } } // diagonaly bool rd = true, ru = true, lu = true, ld = true; for(int i = 0; ld || lu || rd || ru; i++) { if(rd) { _x = qx+i; _y = qy+i; rd = (_x < x-1) && (_y < y-1); if(chessboard[_x][_y] == 0) { chessboard[_x][_y] = 1; result--; } } if(ru) { _x = qx+i; _y = qy-i; ru = (_x < x-1) && (_y > 0); if(chessboard[_x][_y] == 0) { chessboard[_x][_y] = 1; result--; } } if(ld) { _x = qx-i; _y = qy+i; ld = (_x > 0) && (_y < y-1); if(chessboard[_x][_y] == 0) { chessboard[_x][_y] = 1; result--; } } if(lu) { _x = qx-i; _y = qy-i; lu = (_x > 0) && (_y > 0); if(chessboard[_x][_y] == 0) { chessboard[_x][_y] = 1; result--; } } } } // /* for(int i = 0; i < x; i++) { for(int j = 0; j < y; j++) printf("%d ", chessboard[i][j]); printf("\n"); } */ printf("%d\n", result); } // for(int i = 0; i < 20000; i++) delete [] chessboard[i]; delete [] chessboard; // return 0; }