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
#include <cstdio>
#include <cstdlib>
#include <algorithm>

typedef unsigned long long uint64;
typedef long long int64;

uint64 rnd[500001];

std::pair<int, uint64> xs[1000001];
std::pair<int, uint64> ys[1000001];

std::pair<uint64, int> vals[1000001];

int result(std::pair<int, uint64> *s, int n, int m) {
	std::sort(s, s + (2*n));
	s[2*n] = std::make_pair(m, 0);

	int l = 0;
	uint64 h = 0;

	for (int i = 0; i <= 2*n; i++) {
		vals[i] = std::make_pair(h, s[i].first - l);
		l = s[i].first;
		h ^= s[i].second;
	}

	sort(vals, vals + (2*n+1));

	int res = 0;
	int now = 0;
	h = vals[0].first;

	for (int i = 0; i <= 2*n; i++) {
		if (vals[i].first == h) {
			now += vals[i].second;
		}
		else {
			if (res < now)
				res = now;
			h = vals[i].first;
			now = vals[i].second;
		}
	}
	if (res < now)
		res = now;

	return res;
}

int main() {
	srand(3611211);

	int n, max_x, max_y;
	scanf("%d%d%d", &n, &max_x, &max_y);

	for (int i = 0; i < n; i++) {
		rnd[i] = (uint64) rand() ^ ((uint64) rand() << 20) ^ ((uint64) rand() << 40);
	}

	for (int i = 0; i < n; i++) {
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

		if (x1 > x2) std::swap(x1, x2);
		if (y1 > y2) std::swap(y1, y2);

		xs[2*i]   = std::make_pair(x1, rnd[i]);
		xs[2*i+1] = std::make_pair(x2, rnd[i]);
		ys[2*i]   = std::make_pair(y1, rnd[i]);
		ys[2*i+1] = std::make_pair(y2, rnd[i]);
	}

	printf("%lld\n", (int64) result(xs, n, max_x) * result(ys, n, max_y));
}