#include #include using namespace std; #define VEL 20000 void obsad(bool **pole, int x, int y, int a, int b) { pole[a][b] = true; for (int i = 0; i < x; i++) { pole[i][b] = true; } for (int i = 0; i < y; i++) { pole[a][i] = true; } int c, d; c = a; d = b; while (c >= 0 && d >= 0 && c < x && d < y) { pole[c][d] = true; c--; d--; } c = a; d = b; while (c >= 0 && d >= 0 && c < x && d < y) { pole[c][d] = true; c++; d--; } c = a; d = b; while (c >= 0 && d >= 0 && c < x && d < y) { pole[c][d] = true; c++; d++; } c = a; d = b; while (c >= 0 && d >= 0 && c < x && d < y) { pole[c][d] = true; c--; d++; } } int main() { int x, y, n; int a, b; bool **pole; do { cin >> x; cin >> y; cin >> n; if (x+y+n==0) { break; } pole = new bool*[VEL]; for (int i = 0; i < x; i++) { pole[i] = new bool[VEL]; for (int j = 0; j < y; j++) { pole[i][j] = false; } } // obsad for (int i = 0; i < n; i++) { cin >> a; cin >> b; obsad(pole, x, y, a-1, b-1); } /*for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { cout << pole[i][j]; } cout << endl; }*/ // spocitej int cnt = 0; for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { if (!pole[i][j]) { cnt++; } } } cout << cnt << endl; } while(true); return 0; }