1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "bits/stdc++.h"

using namespace std;

using ull = unsigned long long;

int main() {
  ios_base::sync_with_stdio(0);
  mt19937_64 rng(15061994);
  uniform_int_distribution<ull> dis;
  int n, X, Y;
  cin >> n >> X >> Y;
  vector <pair <int, int> > xs, ys;
  for(int i=0; i<n; i++) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    xs.emplace_back(x1, i);
    xs.emplace_back(x2, i);
    ys.emplace_back(y1, i);
    ys.emplace_back(y2, i);
  }
  xs.emplace_back(0, -1);
  ys.emplace_back(0, -1);
  xs.emplace_back(X, n);
  ys.emplace_back(Y, n);
  auto solve = [&](vector <pair <int, int> > ds) {
    vector <ull> hashes(n);
    for(int i=0; i<n; i++) hashes[i] = dis(rng);
    sort(ds.begin(), ds.end());
    unordered_map <ull, int> M;
    ull hash = 0;
    for(int i=1; i<=2*n; i++) {
      M[hash] += ds[i].first - ds[i-1].first;
      hash ^= hashes[ds[i].second];
    }
    M[hash] += ds[2*n+1].first - ds[2*n].first;
    int ret = 0;
    for(auto ele : M) ret = max(ret, ele.second);
    return ret;
  };
  cout << 1LL * solve(xs) * solve(ys) << "\n";
}