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
#include <iostream>
#include <algorithm>
#include <vector>

std::vector<std::vector<int> > intersect(std::vector<std::vector<int> > a, std::vector<std::vector<int> > b) {
    std::vector<std::vector<int> > res;
    std::vector<int> dim;
    for(auto aa : a) {
        for(auto bb : b) {
            if(aa[0] < bb[2] && bb[0] < aa[2] && aa[1] < bb[3] && bb[1] < aa[3]) {
                dim = {std::max(aa[0], bb[0]), std::max(aa[1], bb[1]), std::min(aa[2], bb[2]),  std::min(aa[3], bb[3])};
                res.push_back(dim);
            }
        }
    }
    return res;
}

long long int area(std::vector<std::vector<std::vector<int> > > d) {
    long long int res=0, r;
    for(auto set : d) {
        r = 0;
        for(auto x : set) {
            r += (x[2]-x[0])*(x[3]-x[1]);
        }
        if(res < r) {
            res = r;
        }
    }
    return res;
}

std::vector<std::vector<std::vector<int> > > data, tmp;

int main() {
    std::vector<std::vector<int> > row;
    std::vector<int> dim;
    int n, x, y;
    int x1, y1, x2, y2;
    std::cin >> n >> x >> y;
    dim = {0, 0, x, y};
    row.push_back(dim);
    data.push_back(row);
    while(n--) {
        std::cin >> x1 >> y1 >> x2 >> y2;
        if(x2 < x1) {
            std::swap(x1, x2);
        }
        if(y2 < y1) {
            std::swap(y1, y2);
        }
        tmp = data;
        data.clear();
        for(auto set : tmp) {
            row.clear();
            dim = {x1, y1, x2, y2};
            row.push_back(dim);
            row = intersect(row, set);
            if(row.size()) {
                data.push_back(row);
            }

            row.clear();
            dim = {0, 0, x1, y1};
            row.push_back(dim);
            dim = {0, y2, x1, y};
            row.push_back(dim);
            dim = {x2, 0, x, y1};
            row.push_back(dim);
            dim = {x2, y2, x, y};
            row.push_back(dim);
            row = intersect(row, set);
            if(row.size()) {
                data.push_back(row);
            }

            row.clear();
            dim = {0, y1, x1, y2};
            row.push_back(dim);
            dim = {x2, y1, x, y2};
            row.push_back(dim);
            row = intersect(row, set);
            if(row.size()) {
                data.push_back(row);
            }

            row.clear();
            dim = {x1, 0, x2, y1};
            row.push_back(dim);
            dim = {x1, y2, x2, y};
            row.push_back(dim);
            row = intersect(row, set);
            if(row.size()) {
                data.push_back(row);
            }
        }
        tmp.clear();
    }
    std::cout << area(data) << std::endl;
    data.clear();
    
    return 0;
    
}