#include <iostream> #include <vector> #include <algorithm> #include <cstdint> #include <cstdio> #include <inttypes.h> using namespace std; #define D(x) uint64_t xorshift64() { static uint64_t x = 2431234567897654321LL; x ^= x << 13; x ^= x >> 7; x ^= x << 17; return x; } struct P { int x; uint64_t h; }; vector<P> X,Y; void print(vector<P> &V) { for(auto v:V) { std::cout << v.x << "\t" << v.h << "\n"; } } int find_max(vector<P> &V) { D( print(V); std::cout <<" sorted x\n"); std::sort(V.begin(), V.end(), [](const P& a, const P &b) {return a.x < b.x;} ); D( print(V)); uint64_t h = 0; for(int i=0;i<V.size()-1;i++) { auto &v = V[i]; h ^= v.h; v.h = h; v.x = V[i+1].x - v.x; } V.pop_back(); D( std::cout <<" odl x\n"; print(V)); std::sort(V.begin(), V.end(), [](const P& a, const P &b) {return a.h < b.h;} ); h = 0; int res = 0, odl = 0; for(auto &v: V) { if (v.h != h) { odl = 0; h = v.h; } odl+= v.x; res = max(res, odl); } return res; } void add(int x1,int y1, int x2, int y2) { uint64_t h; h = xorshift64(); X.push_back({x1,h}); X.push_back({x2,h}); Y.push_back({y1,h}); Y.push_back({y2,h}); } int main() { int n,x,y,x1,y1,x2,y2; scanf("%d %d %d", &n, &x, &y); add(0,0,x,y); while(n--) { scanf("%d %d %d %d", &x1, &y1, &x2, &y2); add(x1,y1,x2,y2); } uint64_t rx = find_max(X); uint64_t ry = find_max(Y); printf( "%" PRIu64 "\n", rx*ry); }
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 | #include <iostream> #include <vector> #include <algorithm> #include <cstdint> #include <cstdio> #include <inttypes.h> using namespace std; #define D(x) uint64_t xorshift64() { static uint64_t x = 2431234567897654321LL; x ^= x << 13; x ^= x >> 7; x ^= x << 17; return x; } struct P { int x; uint64_t h; }; vector<P> X,Y; void print(vector<P> &V) { for(auto v:V) { std::cout << v.x << "\t" << v.h << "\n"; } } int find_max(vector<P> &V) { D( print(V); std::cout <<" sorted x\n"); std::sort(V.begin(), V.end(), [](const P& a, const P &b) {return a.x < b.x;} ); D( print(V)); uint64_t h = 0; for(int i=0;i<V.size()-1;i++) { auto &v = V[i]; h ^= v.h; v.h = h; v.x = V[i+1].x - v.x; } V.pop_back(); D( std::cout <<" odl x\n"; print(V)); std::sort(V.begin(), V.end(), [](const P& a, const P &b) {return a.h < b.h;} ); h = 0; int res = 0, odl = 0; for(auto &v: V) { if (v.h != h) { odl = 0; h = v.h; } odl+= v.x; res = max(res, odl); } return res; } void add(int x1,int y1, int x2, int y2) { uint64_t h; h = xorshift64(); X.push_back({x1,h}); X.push_back({x2,h}); Y.push_back({y1,h}); Y.push_back({y2,h}); } int main() { int n,x,y,x1,y1,x2,y2; scanf("%d %d %d", &n, &x, &y); add(0,0,x,y); while(n--) { scanf("%d %d %d %d", &x1, &y1, &x2, &y2); add(x1,y1,x2,y2); } uint64_t rx = find_max(X); uint64_t ry = find_max(Y); printf( "%" PRIu64 "\n", rx*ry); } |