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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#include <bits/stdc++.h>

#define fi first
#define se second
#define ll long long
#define ui unsigned int
#define ld long double
#define pb push_back
#define vi vector<int>

using namespace std;

struct event {
    bool end = false;
    ui cord;
    int rect;
} e;

bool operator<(event a, event b) {
    return a.cord < b.cord;
}

vector<event> QV;
vector<event> QH;
map<vi, long long> M;
int vopen, hopen;
vi key;

void dbgk(char r, event ev) {
    cout << r << ": \nevent: " << ev.rect << " " << ev.cord << endl;
	cout<<"open: "<<vopen<<" "<<hopen<<endl;
    for (int i = 0; i < key.size(); i++)
        cout << key[i] << " ";
    cout << endl;
}

void vreducer(event ev) {
    // dbgk('v', ev);
    if (ev.end) {
        key[ev.rect] = -1;
        vopen--;
    } else if (key[ev.rect] == -1) {
        vopen++;
        key[ev.rect] = 0;
    } else if (key[ev.rect] == 0)
        key[ev.rect] = 10;
    else
        key[ev.rect] = 0;
    // dbgk('v', ev);
}

void hreducer(event ev) {
    // dbgk('h', ev);
	if(key[ev.rect] == -1) {
		return;
	} else if (ev.end) {
        if (key[ev.rect] == 1)
            key[ev.rect] = 0;
        else
            key[ev.rect] = 10;
        hopen--;
    } else if (key[ev.rect] == 0) {
        hopen++;
        key[ev.rect] = 1;
    } else if (key[ev.rect] == 10) {
        hopen++;
        key[ev.rect] = 3;
    } else if (key[ev.rect] == 1) {
        key[ev.rect] = 2;
    } else if (key[ev.rect] == 2) {
        key[ev.rect] = 1;
    } else if (key[ev.rect] == 3) {
        key[ev.rect] = 4;
    } else if (key[ev.rect] == 4) {
        key[ev.rect] = 3;
    }
    // dbgk('h', ev);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, X, Y;
    cin >> n >> X >> Y;

    ui x1, x2, y1, y2;
    key.resize(n);

    for (int i = 0; i < n; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        if (x1 > x2)
            swap(x1, x2);
        if (y1 > y2)
            swap(y1, y2);

        e.rect = i;
        e.cord = y1;
        QV.push_back(e);
        e.cord = y2;
        QV.push_back(e);
        e.cord = Y + y1;
        QV.push_back(e);
        e.cord = Y + y2;
        e.end = true;
        QV.push_back(e);
		e.end = false;

        e.cord = x1;
        QH.push_back(e);
        e.cord = x2;
        QH.push_back(e);
        e.cord = X + x1;
        QH.push_back(e);
        e.cord = X + x2;
		e.end = true;
        QH.push_back(e);
		e.end = false;

        key[i] = -1;
    }

    std::sort(QH.begin(), QH.end());
    std::sort(QV.begin(), QV.end());

    ui q;
    vopen = 0;
    ll field;
	for(int j=0; j<QH.size(); j++) {
        vreducer(QV[j]);
       
        hopen = 0;
        for (int i = 0; i < QH.size(); i++) {
            hreducer(QH[i]);
            if (vopen == n && hopen == n) {
                field = ((ll)(QV[j+1].cord - QV[j].cord)) * ((ll)(QH[i + 1].cord - QH[i].cord));
                // cout << " " << ((ll)(QV[j+1].cord - QV[j].cord)) << " " << ((ll)(QH[i + 1].cord - QH[i].cord)) << endl;
                if (M.find(key) == M.end()) {
                    M[key] = 0;
                }
                M[key] += field;
            }
        }
    }
    ll res = 0;
    for (auto k : M) {
    	int maxkind = 0;
        for (int x : k.first) {
            maxkind = max(maxkind, x);
			// cout<<x<<" "<<maxkind<<" ";
		}
        int div = 1;
        if (maxkind == 2 || maxkind == 3)
            div = 2;
        if (maxkind == 1)
            div = 4;
		// cout<<endl<<" "<<k.second<<" "<<div<<endl;
        res = max(res, k.second / div);
    }

    cout << res << endl;

    return 0;
}