#include #include int width, height, queens; char pole[21000][21000]; int i, j; int max(int a, int b) { return (a > b)? a : b; } void zaznacit(int Qx, int Qy) { for (i = 0; i < width; i++) pole[i][Qy] = 1; for (i = 0; i < height; i++) pole[Qx][i] = 1; int status = 1; for (i = 0; i <= 500000000; i++) { status = 0; if (Qx - i >= 0 && Qy - i >= 0) { pole[Qx - i][Qy - i] = 1; status = 1; } if (Qx + i < width && Qy - i >= 0) { pole[Qx + i][Qy - i] = 1; status = 1; } if (Qx + i < width && Qy + i < height) { pole[Qx + i][Qy + i] = 1; status = 1; } if (Qx - i >= 0 && Qy + i < height) { pole[Qx - i][Qy + i] = 1; status = 1; } if (status == 0) break; } } int main(void) { int counter = 0; int Qx, Qy; int k; while (1) { scanf("%d %d %d\n", &width, &height, &queens); if (width == 0 && height == 0 && queens == 0) { break; } else { for (i = 0; i < width; i++) { for (j = 0; j < height; j++) { pole[i][j] = 0; } } for (k = 0; k < queens; k++) { scanf("%d %d\n", &Qx, &Qy); Qx--; Qy--; zaznacit(Qx, Qy); } for (i = 0; i < width; i++) { for (j = 0; j < height; j++) { if (pole[i][j] == 0) counter++; } } } printf("%d\n", counter); counter = 0; } return 0; }