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
165
166
167
168
169
170
171
172
173
174
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define L long long
#define MP make_pair
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define FORR(i, a, b) for(int i = b - 1; i >= a; --i)
#define EB emplace_back
#define ST first
#define ND second
#define S size()
#define RS resize

using VI = vector<int>;
using VVI = vector<VI>;
using PI = pair<int, int>;
using PL = pair<L, L>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VVPI = vector<VPI>;
using VL = vector<L>;
using VVL = vector<VL>;
using VB = vector<bool>;
using VC = vector<char>;

mt19937_64 gen(42);
L rd(L a, L b) 
{
    return uniform_int_distribution<L>(a, b)(gen);
}

int n, X, Y;
L m = (L)8000000000000;

struct para
{
    int l, p, pl, pp;
};

vector<para> poz, pio;

struct pkt
{
    int x, nr;
    char t;
};

bool operator < (pkt p, pkt q)
{
    return p.x < q.x;
}

vector<pkt> a, b;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> X >> Y;
    poz.RS(n);
    pio.RS(n);
    a.RS(2 * n);
    b.RS(2 * n);
    REP(i, n)
    {
        para nowa1, nowa2;
        cin >> nowa1.l >> nowa2.l >> nowa1.p >> nowa2.p;
        if (nowa1.l > nowa1.p)
            swap(nowa1.l, nowa1.p);
        if (nowa2.l > nowa2.p)
            swap(nowa2.l, nowa2.p);
        poz[i] = nowa1;
        pio[i] = nowa2;
    }
    REP(i, n)
    {
        pkt nowy1, nowy2;
        nowy1.x = poz[i].l;
        nowy2.x = poz[i].p;
        nowy1.t = 'l';
        nowy2.t = 'p';
        nowy1.nr = nowy2.nr = i;
        a[2 * i] = nowy1;
        a[2 * i + 1] = nowy2;
    }
    REP(i, n)
    {
        pkt nowy1, nowy2;
        nowy1.x = pio[i].l;
        nowy2.x = pio[i].p;
        nowy1.t = 'l';
        nowy2.t = 'p';
        nowy1.nr = nowy2.nr = i;
        b[2 * i] = nowy1;
        b[2 * i + 1] = nowy2;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    REP(i, 2 * n)
    {
        if (a[i].t == 'l')
            poz[a[i].nr].pl = i;
        else
            poz[a[i].nr].pp = i;
        if (b[i].t == 'l')
            pio[b[i].nr].pl = i;
        else
            pio[b[i].nr].pp = i;
    }
    VI pa(2 * n), pb(2 * n);
    pa[0] = 1;
    FOR(i, 1, 2 * n)
        pa[i] = pa[i - 1] + 1;
    pb[0] = 1;
    FOR(i, 1, 2 * n)
        pb[i] = pb[i - 1] + 1;
    VI da(2 * n + 1), db(2 * n + 1);
    da[0] = a[0].x;
    db[0] = b[0].x;
    FOR(i, 1, 2 * n)
    {
        da[i] = a[i].x - a[i - 1].x;
        db[i] = b[i].x - b[i - 1].x;
    }
    da[2 * n] = X - a[2 * n - 1].x;
    db[2 * n] = Y - b[2 * n - 1].x;
    VPL prefa(2 * n + 1), prefb(2 * n + 1);
    REP(i, n)
    {
        L r1 = rd(1, m), r2 = rd(1, m), r3 = rd(1, m), r4 = rd(1, m);
        prefa[pa[poz[i].pl]].ST += r1;
        prefa[pa[poz[i].pp]].ST -= r1;
        prefa[0].ST += r2;
        prefa[pa[poz[i].pl]].ST -= r2;
        prefa[pa[poz[i].pp]].ST += r2;
        prefa[pa[poz[i].pl]].ND += r3;
        prefa[pa[poz[i].pp]].ND -= r3;
        prefa[0].ND += r4;
        prefa[pa[poz[i].pl]].ND -= r4;
        prefa[pa[poz[i].pp]].ND += r4;
        prefb[pb[pio[i].pl]].ST += r3;
        prefb[pb[pio[i].pp]].ST -= r3;
        prefb[0].ST += r4;
        prefb[pb[pio[i].pl]].ST -= r4;
        prefb[pb[pio[i].pp]].ST += r4;
        prefb[pb[pio[i].pl]].ND += r1;
        prefb[pb[pio[i].pp]].ND -= r1;
        prefb[0].ND += r2;
        prefb[pb[pio[i].pl]].ND -= r2;
        prefb[pb[pio[i].pp]].ND += r2;
    }
    FOR(i, 1, 2 * n + 1)
    {
        prefa[i].ST += prefa[i - 1].ST;
        prefb[i].ST += prefb[i - 1].ST;
        prefa[i].ND += prefa[i - 1].ND;
        prefb[i].ND += prefb[i - 1].ND;
    }
    map<PL, int> mapa1, mapa2;
    int maks1 = 0, maks2 = 0;
    REP(i, 2 * n + 1)
    {
        mapa1[prefa[i]] += da[i];
        mapa2[prefb[i]] += db[i];
        maks1 = max(maks1, mapa1[prefa[i]]);
        maks2 = max(maks2, mapa2[prefb[i]]);
    }
    L odp = (L)maks1 * (L)maks2;
    cout << odp;
}