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
#include<bits/stdc++.h>
#define ff first
#define sc second
#define mk make_pair

using namespace std;

constexpr int lim = 500009;
int wyn[2],n,X,Y,ii,t[2][lim],us[2][lim];
vector<pair<pair<int,int>,int> > v[2];
vector<int> st;

int main()
{
	scanf("%d%d%d", &n, &X, &Y);
	v[0].push_back(mk(mk(0,-X),n));
	v[0].push_back(mk(mk(X,0),-n));
	v[1].push_back(mk(mk(0,-Y),n));
	v[1].push_back(mk(mk(Y,0),-n));
	for(int i = 0;i<n;++i)
	{
		int x1,x2,y1,y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		if(x1>x2)
		{
			swap(x1,x2);
		}
		if(y1>y2)
		{
			swap(y1,y2);
		}
		v[0].push_back(mk(mk(x1,-x2),i));
		v[0].push_back(mk(mk(x2,-x1),-i));
		v[1].push_back(mk(mk(y1,-y2),i));
		v[1].push_back(mk(mk(y2,-y1),-i));
	}
	for(ii = 0;ii<2;++ii)
	{
		if(st.size()) st.clear();
		sort(v[ii].begin(),v[ii].end());
		st.push_back(v[ii][0].sc);
		//printf("\n%d %d %d\n", v[ii][0].ff.ff, v[ii][0].ff.sc, v[ii][0].sc);
		for(unsigned int i = 1;i<v[ii].size();++i)
		{
			//printf("%d %d %d  %d\n", v[ii][i].ff.ff, v[ii][i].ff.sc, v[ii][i].sc, st.back());
			if(st.size())
			{
				if((v[ii][i].ff.ff<-v[ii][i].ff.sc)||(st.back()==abs(v[ii][i].sc)))
				{
					t[ii][st.back()] += v[ii][i].ff.ff-v[ii][i-1].ff.ff;
					//printf("%d %d %d\n", st.back(), v[ii][i].ff.ff, v[ii][i-1].ff.ff);
				}
				else
				{
					//printf("%d %d %d %d\n", ii, i, st.back(), v[ii][i].sc);
					wyn[ii] = max(wyn[ii],v[ii][i].ff.ff-v[ii][i-1].ff.ff);
				}
			}
			if(v[ii][i].ff.ff<-v[ii][i].ff.sc)
			{
				st.push_back(v[ii][i].sc);
			}
			else
			{
				us[ii][-v[ii][i].sc] = 1;
				while((st.size())&&(us[ii][st.back()]))
				{
					st.pop_back();
				}
			}
		}
		for(int i = 0;i<=n;++i)
		{
			//printf("%d %d: %d\n", ii, i, t[ii][i]);
			wyn[ii] = max(wyn[ii],t[ii][i]);
		}
	}
	printf("%lld\n", (long long)wyn[0]*wyn[1]);
}
/*
4 3 5
1 4 0 1
2 0 1 3
1 0 0 3
2 2 1 3
//*/