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

using namespace std;

typedef long long ll;

int n, m, k;
const int P = 1000000007;

int reg(int x, int y, int mx, int Mx, int my, int My)
{
    if (x >= mx && x < Mx && y >= my && y < My)
        return 3;
    if (x >= mx && x < Mx && y < my)
        return 5;
    if (x >= mx && x < Mx && y >= My)
        return 5;
    if (x < mx && y >= my && y < My)
        return 7;
    if (x >= Mx && y >= my && y < My)
        return 7;
    return 11;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> k >> m >> n;
    vector<int> mx(k), Mx(k), my(k), My(k);
    for (int i = 0; i < k; ++i)
    {
        int a, b, c, d;
        cin >> b >> a >> d >> c;
        mx[i] = min(a, c);
        Mx[i] = max(a, c);
        my[i] = min(b, d);
        My[i] = max(b, d);
    }
    vector<int> tx;
    for (int i = 0; i < k; ++i)
    {
        tx.push_back(mx[i]);
        tx.push_back(Mx[i]);
    }
    tx.push_back(0);
    tx.push_back(n);
    vector<int> ty;
    for (int i = 0; i < k; ++i)
    {
        ty.push_back(my[i]);
        ty.push_back(My[i]);
    }
    ty.push_back(0);
    ty.push_back(m);
    sort(tx.begin(), tx.end());
    sort(ty.begin(), ty.end());
    vector<int> x;
    for (int i = 0; i < tx.size(); ++i)
        if (i == 0 || tx[i] != tx[i - 1])
            x.push_back(tx[i]);
    vector<int> y;
    for (int i = 0; i < ty.size(); ++i)
        if (i == 0 || ty[i] != ty[i - 1])
            y.push_back(ty[i]);
    map<int, ll> M;
    for (int i = 0; i < x.size() - 1; ++i)
    {
        for (int j = 0; j < y.size() - 1; ++j)
        {
            int h = 0;
            for (int l = 0; l < k; ++l)
                h = h * P + reg(x[i], y[j], mx[l], Mx[l], my[l], My[l]);
            M[h] += (ll) (x[i + 1] - x[i]) * (ll) (y[j + 1] - y[j]);
        }
    }
    ll odp = 0;
    for (map<int, ll>::iterator it = M.begin(); it != M.end(); ++it)
        odp = max(odp, it->second);
    cout << odp;
    return 0;
}