#include <iostream> #include <algorithm> #include <unordered_map> uint64_t mod = 5527728924058771ull; uint64_t B = 113; uint64_t n,x,y; const int MAX = 500005; struct E { uint64_t v; uint64_t c; bool operator<(const E& e) const { if (v == e.v) return c < e.c; else return v < e.v; } } X[2*MAX], Y[2*MAX]; int main() { std::ios_base::sync_with_stdio(0); std::cin >> n >> x >> y; uint64_t BB = B; for (int i=0;i<n;++i) { BB = (BB*B)%mod; uint64_t x1,y1,x2,y2; std::cin >> x1 >> y1 >> x2 >> y2; if (x1>x2) std::swap(x1,x2); if (y1>y2) std::swap(y1,y2); X[2*i] = {x1, BB}; X[2*i+1] = {x2, mod-BB}; Y[2*i] = {y1, BB}; Y[2*i+1] = {y2, mod-BB}; } X[2*n] = {x, 0ull}; Y[2*n] = {y, 0ull}; std::unordered_map<uint64_t, uint64_t> XX; std::unordered_map<uint64_t, uint64_t> YY; std::sort(X, X+2*n); std::sort(Y, Y+2*n); int64_t hash = 0; int64_t lx = 0; for (int i=0;i<=2*n;++i) { if (X[i].v > lx) { XX[hash] += X[i].v-lx; lx = X[i].v; } hash = (hash+X[i].c)%mod; } hash = 0; int64_t ly = 0; for (int i=0;i<=2*n;++i) { if (Y[i].v > ly) { YY[hash] += Y[i].v-ly; ly = Y[i].v; } hash = (hash+Y[i].c)%mod; } uint64_t resultx = 0; for (auto it : XX) { resultx = std::max(resultx, it.second); } uint64_t resulty = 0; for (auto it : YY) { resulty = std::max(resulty, it.second); } std::cout << resultx*resulty << std::endl; return 0; }
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 | #include <iostream> #include <algorithm> #include <unordered_map> uint64_t mod = 5527728924058771ull; uint64_t B = 113; uint64_t n,x,y; const int MAX = 500005; struct E { uint64_t v; uint64_t c; bool operator<(const E& e) const { if (v == e.v) return c < e.c; else return v < e.v; } } X[2*MAX], Y[2*MAX]; int main() { std::ios_base::sync_with_stdio(0); std::cin >> n >> x >> y; uint64_t BB = B; for (int i=0;i<n;++i) { BB = (BB*B)%mod; uint64_t x1,y1,x2,y2; std::cin >> x1 >> y1 >> x2 >> y2; if (x1>x2) std::swap(x1,x2); if (y1>y2) std::swap(y1,y2); X[2*i] = {x1, BB}; X[2*i+1] = {x2, mod-BB}; Y[2*i] = {y1, BB}; Y[2*i+1] = {y2, mod-BB}; } X[2*n] = {x, 0ull}; Y[2*n] = {y, 0ull}; std::unordered_map<uint64_t, uint64_t> XX; std::unordered_map<uint64_t, uint64_t> YY; std::sort(X, X+2*n); std::sort(Y, Y+2*n); int64_t hash = 0; int64_t lx = 0; for (int i=0;i<=2*n;++i) { if (X[i].v > lx) { XX[hash] += X[i].v-lx; lx = X[i].v; } hash = (hash+X[i].c)%mod; } hash = 0; int64_t ly = 0; for (int i=0;i<=2*n;++i) { if (Y[i].v > ly) { YY[hash] += Y[i].v-ly; ly = Y[i].v; } hash = (hash+Y[i].c)%mod; } uint64_t resultx = 0; for (auto it : XX) { resultx = std::max(resultx, it.second); } uint64_t resulty = 0; for (auto it : YY) { resulty = std::max(resulty, it.second); } std::cout << resultx*resulty << std::endl; return 0; } |