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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " " << x << endl;

// #define int long long // uważaj

const int N = 1e6 + 7;

long long solve(vector<pair<int, int> > vek) {
    vector<unsigned long long> hasze;

    for(int i = 0; i < vek.size() + 10; i++) {
        unsigned long long zm = rand();
        zm <<= 32;
        zm += rand();
        hasze.push_back(zm);
    }
    map<unsigned long long, int> mapa;

    sort(vek.begin(), vek.end());

    unsigned long long akt = 0;

    for(int i = 0; i + 1 < vek.size(); i++) {
        akt ^= hasze[vek[i].second];
        mapa[akt] += vek[i + 1].first - vek[i].first;
    }

    int ret = 0;

    for(auto x : mapa) ret = max(ret, x.second);

    return ret;
}

int32_t main(){
    srand(time(0));
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, X, Y;
    vector<pair<int, int>> vek1, vek2;

    cin >> n >> X >> Y;

    for(int i = 1; i <= n; i++) {
        int xa, xb, ya, yb;
        cin >> xa >> ya >> xb >> yb;
        vek1.push_back({xa, i});
        vek1.push_back({xb, i});
        vek2.push_back({ya, i});
        vek2.push_back({yb, i});
    }
    vek1.push_back({0, 0});
    vek2.push_back({0, 0});
    vek1.push_back({X, 0});
    vek2.push_back({Y, 0});

    cout << solve(vek1) * solve(vek2) << endl;
}