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
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
#include <bits/stdc++.h>
using namespace std;

const int INF = 2e9;
const int MAXN = 500002;

vector<long long> powers;
long long M, P;

class HashSet {
public:
    HashSet() {
        hash = 0;
    }
    void changeValue(int i) {
        if (bits[i] == 0) {
            hash = (hash + powers[i]) % M;
            bits[i] = 1;
        }
        else if (bits[i] == 1) {
            hash = (hash - powers[i] + M) % M;
            bits[i] = 0;
        }
    }
    long long getHash() {
        return hash;
    }
private:
    bitset<MAXN> bits;
    long long hash;
};

int main() {
    ios_base::sync_with_stdio(false);
    int n, x, y;
    cin >> n >> x >> y;
    M = 1000000007;
    P = 31;
    powers.push_back(1);
    for (int i = 1; i <= n; i++) {
        powers.push_back((powers.back() * P) % M);
    }
    HashSet xx;
    HashSet yy;
    vector <pair<int, int> > x_vec;
    vector <pair<int, int> > y_vec;
    unordered_map <long long, int> x_map;
    unordered_map <long long, int> y_map;
    for (int i = 0; i < n; i++) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        x_vec.push_back(make_pair(x1, i));
        x_vec.push_back(make_pair(x2, i));
        y_vec.push_back(make_pair(y1, i));
        y_vec.push_back(make_pair(y2, i));
    }
    sort(x_vec.begin(), x_vec.end());
    sort(y_vec.begin(), y_vec.end());
    x_map[xx.getHash()] = x_vec.front().first;
    x_map[xx.getHash()] += x - x_vec.back().first;
    int x_max = x_map[xx.getHash()];
    int previous_x = x_vec.front().first;
    for (int i = 0; i < 2 * n;) {
        while(i < 2 * n && x_vec[i].first == previous_x) {
            xx.changeValue(x_vec[i].second);
            i++;
        }
        if (i < 2 * n) {
            x_map[xx.getHash()] += (x_vec[i].first - previous_x);
            x_max = max(x_max, x_map[xx.getHash()]);
            previous_x = x_vec[i].first;
        }
    }
    // cout << "vector" << endl;
    // for (auto& x : x_vec) {
    //     cout << x.first << " " << x.second << endl;
    // }
    // cout << "map" << endl;
    // for (auto& x : x_map) {
    //     cout << x.first <<  " " << x.second << endl;
    // }

    
    y_map[yy.getHash()] = y_vec.front().first;
    y_map[yy.getHash()] += y - y_vec.back().first;
    int y_max = y_map[yy.getHash()];
    int previous_y = y_vec.front().first;
    for (int i = 0; i < 2 * n;) {
        while(i < 2 * n && y_vec[i].first == previous_y) {
            yy.changeValue(y_vec[i].second);
            i++;
        }
        if (i < 2 * n) {
            y_map[yy.getHash()] += (y_vec[i].first - previous_y);
            y_max = max(y_max, y_map[yy.getHash()]);
            previous_y = y_vec[i].first;
        }
    }
    // cout << "vector" << endl;
    // for (auto& y : y_vec) {
    //     cout << y.first << " " << y.second << endl;
    // }
    // cout << "map" << endl;
    // for (auto& y : y_map) {
    //     cout << y.first <<  " " << y.second << endl;
    // }
    cout << (long long)x_max * y_max << endl;
    return 0;
}