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
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
using namespace std;

#define int long long

struct event{
    int val;
    int id;
    int co;
    event(){}
    event(int val, int id, int co){
        this->val=val;
        this->id=id;
        this->co=co;
    }
};

bool comp(event a, event b){
    if(a.val==b.val)
        return a.co>b.co;
    else return a.val<b.val;
}

int n, X, Y;
const int inf=1e9+3;

int solve(vector<pair<int, int> > &proste, int hej){
    vector<event> rzeczy;
    for(int i=0; i<proste.size(); i++){
        rzeczy.push_back(event(proste[i].first, i, 0) );
        rzeczy.push_back(event(proste[i].second, i, 1) );
    }
    sort(rzeczy.begin(), rzeczy.end(), comp);
    map<pair<int, int>, int> mapka;
    priority_queue<pair<int, int> , vector<pair<int, int> >, greater<pair<int, int> > > q;
    q.push(make_pair(inf, -1));
    int pos=0, res=0;
    for(int i=0; i<rzeczy.size(); i++){
        pair<int, int> temp=make_pair(q.top().first, q.size());
        if(rzeczy[i].co==0){
        //    cout<<i<<" "<<temp.first<<" "<<temp.second<<endl;
            mapka[temp]+=rzeczy[i].val-pos;
            q.push(make_pair(proste[rzeczy[i].id].second, rzeczy[i].id));
            pos=rzeczy[i].val;
            res=max(res, mapka[temp]);
            //cout<<res<<endl;
        }
        else{
            //cout<<i<<" "<<temp.first<<" "<<temp.second<<endl;
            mapka[temp]+=rzeczy[i].val-pos;
            q.pop();
            pos=rzeczy[i].val;
            res=max(res, mapka[temp]);
            //cout<<res<<endl;
        }
    }
    if(hej==0){
        mapka[make_pair(inf, 1)]+=X-pos;
        res=max(res, mapka[make_pair(inf, 1)]);
    }
    if(hej==1){
        mapka[make_pair(inf, 1)]+=Y-pos;
        res=max(res, mapka[make_pair(inf, 1)]);
    }
//    cout<<res<<endl;
    return res;
}

void test(){
    vector<pair<int, int> > prosteX, prosteY;
    cin>>n>>X>>Y;
    for(int i=0; i<n; i++){
        int ax, ay, bx, by;
        cin>>ax>>ay>>bx>>by;
        if(ax>bx) swap(ax, bx);
        if(ay>by) swap(ay, by);
        prosteX.push_back(make_pair(ax, bx));
        prosteY.push_back(make_pair(ay, by));
    }
    int x=solve(prosteX, 0);
    int y=solve(prosteY, 1);
    //cout<<x<<" "<<y<<endl;
    long long wynik=x*y;
    cout<<wynik<<"\n";
}

#define int int

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    test();
}