fork download
  1. #include <bits/stdc++.h>
  2. #define pii pair<int, int>
  3. #define ll long long
  4. using namespace std;
  5. const int N = 5e4 + 5;
  6.  
  7. pii a[N * 4];
  8. int m, n, k;
  9. bool cmp_x(const pii &x, const pii &y)
  10. {
  11. if (x.first != y.first) return x.first < y.first;
  12. return x.second < y.second;
  13. }
  14.  
  15. bool cmp_y(const pii &x, const pii &y)
  16. {
  17. return x.second < y.second;
  18. }
  19.  
  20. void solve()
  21. {
  22. cin >> m >> n >> k;
  23. int total = 4 * k;
  24. for (int i = 0; i < total; ++i)
  25. cin >> a[i].first >> a[i].second;
  26.  
  27. sort(a, a + total, cmp_x);
  28.  
  29. ll diff = 1LL * a[2 * k].first - a[2 * k - 1].first;
  30.  
  31. sort(a, a + 2 * k, cmp_y);
  32. int l1 = a[k - 1].second;
  33. int r1 = a[k].second;
  34.  
  35. sort(a + 2 * k, a + 4 * k, cmp_y);
  36. int l2 = a[2 * k + k - 1].second;
  37. int r2 = a[2 * k + k].second;
  38.  
  39. int both = max(0, min(r1, r2) - max(l1, l2));
  40. cout << diff * 1LL * both;
  41. }
  42.  
  43. int main()
  44. {
  45. ios::sync_with_stdio(false);
  46. cin.tie(nullptr);
  47. solve();
  48. return 0;
  49. }
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
Standard output is empty