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
#include <bits/stdc++.h>

using namespace std;
#define PII pair<int,int>

const int mod=1e9+7;

set<PII> S1,S2;
map<long long,int> M1,M2;
long long val[500005];

int main()
{
    ios_base::sync_with_stdio(0);
    srand(74571);
    int n,X,Y;
    cin>>n>>X>>Y;
    for(int i=1;i<=n;i++)
    {
        int x,y;
        cin>>x>>y;
        S1.insert({x,i});
        S2.insert({y,i});
        cin>>x>>y;
        S1.insert({x,i});
        S2.insert({y,i});
    }

    for(int i=1;i<=n;i++)
    {
        val[i]=(((long long)rand()*rand()*rand())%mod)*rand()*rand();
    }

    int max1=0, max2=0;
    long long mask1=0, mask2=0;
    int d1=0, d2=0;
    for(PII u:S1)
    {
        M1[mask1]+=u.first-d1;
        max1=max(max1,M1[mask1]);
        d1=u.first;
        mask1^=val[u.second];
    }
    M1[mask1]+=X-d1;
    max1=max(max1,M1[mask1]);
    for(PII u:S2)
    {
        M2[mask2]+=u.first-d2;
        max2=max(max2,M2[mask2]);
        d2=u.first;
        mask2^=val[u.second];
    }
    M2[mask2]+=Y-d2;
    max2=max(max2,M2[mask2]);
    cout<<(long long)max1*max2<<endl;
}