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

long long int exp = 37;
long long int mod = 1000000000000037;
long long int power[1000005];
priority_queue<pair<int, int> > que_down;
priority_queue<pair<int, int> > que_left;

map<long long int, long long int> map_down;
map<long long int, long long int> map_left;

void count_powers(int last) {
	power[0] = 1;
	for (int i = 1; i <= last + 1; i++) {
		power[i] = (power[i-1] * exp) % mod;
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	long long int n, X, Y;
	long long int x1, y1, x2, y2, x, y, num;
	pair<long long int, long long int> qtop;
	cin >> n >> X >> Y;
	for(int i = 1; i <= n; i++) {
		cin >> x1 >> y1 >> x2 >> y2;
		que_down.push(make_pair((-1)*min(x1,x2), i));
		que_down.push(make_pair((-1)*max(x1,x2), -i));
		que_left.push(make_pair((-1)*min(y1,y2), i));
		que_left.push(make_pair((-1)*max(y1,y2), -i));
	}
	
	que_down.push(make_pair(0, 0));
	que_down.push(make_pair(-X, 0));
	que_left.push(make_pair(0, 0));
	que_left.push(make_pair(-Y, 0));
	
	
	count_powers(2*n+1);
	
	long long int best_down = 0, best_left = 0;
	long long int current = 0;
	long long int len;
	
	while(!que_down.empty()) {
		qtop = que_down.top();
		x = (-1)*qtop.first;
		num = qtop.second;
		que_down.pop();
		if(que_down.empty()) {
			break;
		}
		if(num < 0) {
			current = (current + mod - power[-num])%mod;
		} else {
			current = (current + power[num])%mod;
		}
		len = ((-1)*que_down.top().first) - x;
		map_down[current] += len;
		best_down = max(best_down, map_down[current]);
	}
	
	current = 0;
	
	while(!que_left.empty()) {
		qtop = que_left.top();
		y = (-1)*qtop.first;
		num = qtop.second;
		
		que_left.pop();
		if(que_left.empty()) {
			break;
		}
		if(num < 0) {
			current = (current + mod - power[-num])%mod;
		} else {
			current = (current + power[num])%mod;
		}
		len = ((-1)*que_left.top().first) - y;
		map_left[current] += len;
		best_left = max(best_left, map_left[current]);
	}
	
	cout << best_down*best_left << endl;
	
	return 0;
}