#include // created [2019/12/23] 00:51:38 #pragma GCC diagnostic ignored "-Wsign-compare" #pragma GCC diagnostic ignored "-Wsign-conversion" using i32 = int32_t; using i64 = int64_t; using u32 = uint32_t; using u64 = uint64_t; using uint = unsigned int; using usize = std::size_t; using ll = long long; using ull = unsigned long long; using ld = long double; template using arr = T (&)[n]; template using c_arr = const T (&)[n]; template constexpr T popcount(const T u) { return u ? static_cast(__builtin_popcountll(static_cast(u))) : static_cast(0); } template constexpr T log2p1(const T u) { return u ? static_cast(64 - __builtin_clzll(static_cast(u))) : static_cast(0); } template constexpr T msbp1(const T u) { return log2p1(u); } template constexpr T lsbp1(const T u) { return __builtin_ffsll(u); } template constexpr T clog(const T u) { return u ? log2p1(u - 1) : static_cast(u); } template constexpr bool ispow2(const T u) { return u and (static_cast(u) & static_cast(u - 1)) == 0; } template constexpr T ceil2(const T u) { return static_cast(1) << clog(u); } template constexpr T floor2(const T u) { return u == 0 ? static_cast(0) : static_cast(1) << (log2p1(u) - 1); } template constexpr bool btest(const T mask, const usize ind) { return static_cast((static_cast(mask) >> ind) & static_cast(1)); } template void bset(T& mask, const usize ind) { mask |= (static_cast(1) << ind); } template void breset(T& mask, const usize ind) { mask &= ~(static_cast(1) << ind); } template void bflip(T& mask, const usize ind) { mask ^= (static_cast(1) << ind); } template void bset(T& mask, const usize ind, const bool b) { (b ? bset(mask, ind) : breset(mask, ind)); } template constexpr T bcut(const T mask, const usize ind) { return ind == 0 ? static_cast(0) : static_cast((static_cast(mask) << (64 - ind)) >> (64 - ind)); } template bool chmin(T& a, const T& b) { return (a > b ? a = b, true : false); } template bool chmax(T& a, const T& b) { return (a < b ? a = b, true : false); } constexpr unsigned int mod = 1000000007; template constexpr T inf_v = std::numeric_limits::max() / 4; template constexpr Real pi_v = Real{3.141592653589793238462643383279502884}; auto mfp = [](auto&& f) { return [=](auto&&... args) { return f(f, std::forward(args)...); }; }; template T in() { T v; return std::cin >> v, v; } template T in_v(typename std::enable_if<(i == n), c_arr>::type) { return in(); } template auto in_v(typename std::enable_if<(i < n), c_arr>::type& szs) { const usize s = (usize)szs[i]; std::vector(szs))> ans(s); for (usize j = 0; j < s; j++) { ans[j] = in_v(szs); } return ans; } template auto in_v(c_arr szs) { return in_v(szs); } template auto in_t() { return std::tuple...>{in()...}; } struct io_init { io_init() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(20); } void clear() { std::cin.tie(), std::ios::sync_with_stdio(true); } } io_setting; template int out(const T& v) { return std::cout << v, 0; } template int out(const std::vector& v) { for (usize i = 0; i < v.size(); i++) { if (i > 0) { std::cout << ' '; } out(v[i]); } return std::cout << "\n", 0; } template int out(const std::pair& v) { return out(v.first), std::cout << ' ', out(v.second), 0; } template int out(const T& v, const Args... args) { return out(v), std::cout << ' ', out(args...), 0; } template int outln(const Args... args) { return out(args...), std::cout << '\n', 0; } template void outel(const Args... args) { return out(args...), std::cout << std::endl, 0; } # define SHOW(...) static_cast(0) constexpr ull TEN(const usize n) { return n == 0 ? 1ULL : TEN(n - 1) * 10ULL; } template auto make_v(typename std::enable_if<(i == n), c_arr>::type, const T& v = T{}) { return v; } template auto make_v(typename std::enable_if<(i < n), c_arr>::type szs, const T& v = T{}) { const usize s = (usize)szs[i]; return std::vector(szs, v))>(s, make_v(szs, v)); } template auto make_v(c_arr szs, const T& t = T{}) { return make_v(szs, t); } int main() { auto L1 = [&](const ll x1, const ll y1, const ll x2, const ll y2) { return std::abs(x1 - x2) + std::abs(y1 - y2); }; auto Linf = [&](const ll x1, const ll y1, const ll x2, const ll y2) { return std::max(std::abs(x1 - x2), std::abs(y1 - y2)); }; auto W = in(), H = in(); const auto N = in(); std::vector rxs(N), rys(N); for (int i = 0; i < N; i++) { rxs[i] = in(), rys[i] = in(); } { std::set mod; for (int i = 0; i < N; i++) { mod.insert(L1(rxs[i], rys[i], 0, 0) % 2); } if (mod.size() == 2) { return outln(0); } } if (N < 12) { assert(false); // やる(dekinai) } std::vector xs(N), ys(N); auto make = [&]() { for (int i = 0; i < N; i++) { xs[i] = rxs[i] + rys[i], ys[i] = rxs[i] - rys[i]; } }; auto flip = [&]() { std::swap(W, H), std::swap(rxs, rys), make(); }; auto xflip = [&]() { for (int i = 0; i < N; i++) { rxs[i] = W + 1 - rxs[i]; } make(); }; auto solve = [&]() -> bool { make(); std::map> xis; for (int i = 0; i < N; i++) { xis[xs[i]].push_back(i); } ll vx = -1; // 縦に3点乗っている直線 for (int i = 0; i < N; i++) { const ll x = xs[i]; if (xis[x].size() >= 3) { vx = x; } } if (vx == -1) { return false; } if (xis[vx].size() == N) { ll rxmin = inf_v, rxmax = -inf_v; ll rymin = inf_v, rymax = -inf_v; for (const int i : xis[vx]) { chmin(rxmin, rxs[i]), chmax(rxmax, rxs[i]); chmin(rymin, rys[i]), chmax(rymax, rys[i]); } outln(rxmin * rymin + (W - rxmax + 1) * (H - rymax + 1)); return true; } int oi = -1; // 外の点 for (int i = 0; i < N; i++) { const ll x = xs[i]; if (x <= vx) { continue; } if (xis.count(x)) { oi = i; } } if (oi == -1) { xflip(); vx = W + 1 - vx; xis.clear(); for (int i = 0; i < N; i++) { xis[xs[i]].push_back(i); } for (int i = 0; i < N; i++) { const ll x = xs[i]; if (x <= vx) { continue; } if (xis.count(x)) { oi = i; } } } ll vymin = inf_v, vymax = -inf_v; for (const int i : xis[vx]) { chmin(vymin, ys[i]), chmax(vymax, rys[i]); } const ll oy = ys[oi]; if (vymin < oy and oy < vymax) { return false; } ll cy = 0, cx = 0; // 中心の乗る半直線の開始地点 if (oy >= vymax) { cy = vymin + oy, cx = vx + oy - vymin; if (cy % 2 == 1 or cx % 2 == 1) { return false; } cy /= 2, cx /= 2; // 半直線は(cx,cy)から(1,-1)方向 const ll y_x = cy - cx; ll d_above = -1, d_below = -1; for (int i = 0; i < N; i++) { bool above = (ys[i] - xs[i]) >= y_x; const ll d = Linf(xs[i], ys[i], cx, cy); if (above) { if (d_above != -1 and d_above != d) { return false; } d_above = d; } else { if (d_below != -1 and d_below != d) { return false; } d_below = d; } } if (d_above == -1) { return false; } if (d_below == -1) { ll p = cx + cy, q = cx - cy; if (p % 2 == 1 or q % 2 == 1) { return false; } p /= 2, q /= 2; if (p < 1 or W < p) { return false; } if (q < 1 or H < q) { return false; } outln(H - q + 1); return true; } else { if (d_above > d_below) { return false; } ll l = d_below - d_above; if (l % 2 == 1) { return false; } l /= 2; const ll x = cx + l, y = cy - l; ll p = x + y, q = x - y; if (p % 2 == 1 or q % 2 == 1) { return false; } p /= 2, q /= 2; if (p < 1 or W < p) { return false; } if (q < 1 or H < q) { return false; } outln(1); return true; } } else { cy = vymax + oy, cx = vx + vymax - oy; if (cy % 2 == 1 or cx % 2 == 1) { return false; } cy /= 2, cx /= 2; // 半直線は(cx,cy)から(1,1)方向 const ll y_x = cy + cx; ll d_above = -1, d_below = -1; for (int i = 0; i < N; i++) { bool above = (ys[i] + xs[i]) <= y_x; const ll d = Linf(xs[i], ys[i], cx, cy); if (above) { if (d_above != -1 and d_above != d) { return false; } d_above = d; } else { if (d_below != -1 and d_below != d) { return false; } d_below = d; } } if (d_above == -1) { return false; } if (d_below == -1) { ll p = cx + cy, q = cx - cy; if (p % 2 == 1 or q % 2 == 1) { return false; } p /= 2, q /= 2; if (p < 1 or W < p) { return false; } if (q < 1 or H < q) { return false; } outln(W - p + 1); return true; } else { if (d_above > d_below) { return false; } ll l = d_below - d_above; if (l % 2 == 1) { return false; } l /= 2; const ll x = cx + l, y = cy + l; ll p = x + y, q = x - y; if (p % 2 == 1 or q % 2 == 1) { return false; } p /= 2, q /= 2; if (p < 1 or W < p) { return false; } if (q < 1 or H < q) { return false; } outln(1); return true; } } }; if (not solve()) { flip(); if (not solve()) { return outln(0); } } return 0; }