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
105
106 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 1;
const long long MOD1 = 1e9 + 696969;
const long long MOD2 = 1e9 + 7;
#define st first
#define nd second
#define mp make_pair
#define PLII pair<long long, long long>
#define LL long long
long long n, x, y;
pair<pair<long long, long long>, pair<long long, long long> > tab[MAXN];
long long res;
long long pot1[MAXN], pot2[MAXN];
map<PLII, LL> wyn;
int main()
{
scanf("%lld%lld%lld", &n, &x, &y);
for(int i = 1; i <= n; i++)
scanf("%lld%lld%lld%lld", &tab[i].st.st, &tab[i].st.nd, &tab[i].nd.st, &tab[i].nd.nd);
pot1[1] = pot2[1] = 1;
for(int i = 2; i <= n; i++) {
pot1[i] = (pot1[i-1] * 2) % MOD1;
pot2[i] = (pot2[i-1] * 2) % MOD2;
}
long long best_res = 0;
long long haszyk1 = 0, haszyk2 = 0;
vector<pair<long long, pair<int, int> > > sorted;
for(int i = 1; i <= n; i++) {
long long x1 = min(tab[i].st.st, tab[i].nd.st);
long long x2 = max(tab[i].st.st, tab[i].nd.st);
sorted.push_back({x1, {1, i}});
sorted.push_back({x2, {-1, i}});
}
sort(sorted.begin(), sorted.end());
long long len = sorted[0].st;
wyn[mp(0LL, 0LL)] = len;
best_res = len;
for(int i = 0; i < sorted.size(); i++) {
int nr = sorted[i].nd.nd;
long long dis = sorted[i].st;
if(sorted[i].nd.st == 1) {
haszyk1 = (haszyk1 + pot1[nr]) % MOD1;
haszyk2 = (haszyk2 + pot2[nr]) % MOD2;
}
else {
haszyk1 = (haszyk1 - pot1[nr] + MOD1) % MOD1;
haszyk2 = (haszyk2 - pot2[nr] + MOD2) % MOD2;
}
if(i == sorted.size() - 1) {
wyn[mp(0LL, 0LL)] += x - dis;
best_res = max(best_res, wyn[mp(0LL, 0LL)]);
}
else {
long long next = sorted[i+1].st;
wyn[mp(haszyk1, haszyk2)] += next - dis;
best_res = max(best_res, wyn[mp(haszyk1, haszyk2)]);
}
}
// if(haszyk1 || haszyk2)
// printf("DHUI1\n");
res = best_res;
wyn.clear();
best_res = 0;
haszyk1 = haszyk2 = 0;
sorted.clear();
for(int i = 1; i <= n; i++) {
long long y1 = min(tab[i].st.nd, tab[i].nd.nd);
long long y2 = max(tab[i].st.nd, tab[i].nd.nd);
sorted.push_back({y1, {1, i}});
sorted.push_back({y2, {-1, i}});
}
sort(sorted.begin(), sorted.end());
wyn[mp(0LL, 0LL)] = sorted[0].st;
best_res = sorted[0].st;
for(int i = 0; i < sorted.size(); i++) {
int nr = sorted[i].nd.nd;
long long dis = sorted[i].st;
if(sorted[i].nd.st == 1) {
haszyk1 = (haszyk1 + pot1[nr]) % MOD1;
haszyk2 = (haszyk2 + pot2[nr]) % MOD2;
}
else {
haszyk1 = (haszyk1 - pot1[nr] + MOD1) % MOD1;
haszyk2 = (haszyk2 - pot2[nr] + MOD2) % MOD2;
}
if(i == sorted.size() - 1) {
wyn[mp(0LL, 0LL)] += y - dis;
best_res = max(best_res, wyn[mp(0LL, 0LL)]);
}
else {
long long next = sorted[i+1].st;
wyn[mp(haszyk1, haszyk2)] += next - dis;
best_res = max(best_res, wyn[mp(haszyk1, haszyk2)]);
}
}
// if(haszyk1 || haszyk2)
// printf("HUJ2\n");
res *= best_res;
printf("%lld\n", res);
}
|