bool g[N][N]; PII match[N][N]; bool st[N][N]; int dx[8] = {-2, -1, 1, 2, -2, 1, -1, 2}; int dy[8] = {1, 2, 2, 1, -1, -2, -2, -1}; int n, m, k;
boolhungary(PII t){ for (int i = 0; i < 8; i++) { int nx = t.first + dx[i]; int ny = t.second + dy[i]; if (nx < 1 || nx > n || ny < 1 || ny > m) continue; if (st[nx][ny] || g[nx][ny]) continue; st[nx][ny] = true; if (!match[nx][ny].first || hungary(match[nx][ny])) { match[nx][ny] = t; returntrue; } } returnfalse; }
cin >> n >> m >> k; for (int i = 1; i <= k; i++) { int a, b; cin >> a >> b; g[a][b] = true; } int res = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if ((i + j) % 2 || g[i][j]) continue; memset(st, false, sizeof st); if (hungary((PII) {i, j})) res++; } } cout << n * m - res - k << endl; return0; }