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
 98
 99
100
101
102
103
104
#include <bits/stdc++.h>
#define sz size()
#define pb push_back
#define ff first
#define ss second

using namespace std;

struct rec {int x1,y1,x2,y2;};
struct pln {vector <rec> t;};

rec mr(int x1, int y1, int x2, int y2) {
	if (x1>x2) swap(x1,x2);
	if (y1>y2) swap(y1,y2);
	return {x1,y1,x2,y2};
}

bool operator!=(rec a, rec b) {
	return a.x1!=b.x1 || a.y1!=b.y1 || a.x2!=b.x2 || a.y2!=b.y2;
}

long long area(rec a) {
	return (long long)(a.x2-a.x1) * (long long)(a.y2-a.y1);
}

long long area(pln a) {
	long long w=0;
	for (auto i: a.t) {
		w+=area(i);
	}
	return w;
}

rec merge(rec a, rec b) {
	rec w;
	w.x1=max(a.x1,b.x1);
	w.x2=min(a.x2,b.x2);
	w.y1=max(a.y1,b.y1);
	w.y2=min(a.y2,b.y2);
	if (w.x1>=w.x2 || w.y1>=w.y2) w={0,0,0,0};
	return w;
}

pln merge(pln a, pln b) {
	pln w; rec h;
	for (auto i: a.t) {
		for (auto j: b.t) {
			h=merge(i,j);
			if (h!=mr(0,0,0,0)) {
				w.t.pb(h);
			}
		}
	}
	return w;
}

int q,n,m,xa,ya,xb,yb;
pln t[500000][4],h;
long long g;
pair <long long,pln> dp[500000][4];

long long calc(int a, pln p) {
	if (a==q) return area(p);
	else {
		if (p.t.sz==0) return 0;
		else return max(
			max(
				calc(a+1,merge(p,t[a][0])),
				calc(a+1,merge(p,t[a][1]))
			),max(
				calc(a+1,merge(p,t[a][2])),
				calc(a+1,merge(p,t[a][3]))
			)
		);
	}
}

int main() {
	scanf("%d %d %d",&q,&n,&m);
	for (int i=0; i<q; ++i) {
		scanf("%d %d %d %d",&xa,&ya,&xb,&yb);
		if (xa>xb) swap(xa,xb);
		if (ya>yb) swap(ya,yb);
		t[i][0]={{
			mr(xa,ya,xb,yb)
		}};
		t[i][1]={{
			mr(0,ya,xa,yb),
			mr(xb,ya,n,yb)
		}};
		t[i][2]={{
			mr(xa,0,xb,ya),
			mr(xa,yb,xb,m)
		}};
		t[i][3]={{
			mr(0,0,xa,ya),
			mr(0,m,xa,yb),
			mr(n,0,xb,ya),
			mr(n,m,xb,yb)
		}};
	}
	printf("%lld\n",max(max(calc(1,t[0][0]),calc(1,t[0][1])),max(calc(1,t[0][2]),calc(1,t[0][3]))));
	return 0;
}