#include <iostream> #include <vector> #include <cstdio> #include <algorithm> #include <map> using namespace std; typedef long long LL; vector<pair<int, int> > vx; vector<pair<int, int> > vy; vector<pair<int, int> > pts; int n, X ,Y; map<int, int> mp; int W[1000005]; int hsh(int i) { return (i*i + pts[i].first * 1000300031 * (pts[i].second))%1000300057; } int gm(vector<pair<int, int> >& v, int a, int b) { mp.clear(); std::fill(W, W+1000000, 0); int hh = 0; int i=0; while (i < 2*n && v[i].first < a) i++; const int pp = i; int jj=i; while (v[jj].first == a) { int p = v[jj].second; int hs = hsh(p); if (!W[p]) { W[p]=1; hh += hs; hh %= 1000300079; } jj++; } mp[hh] = (v[i].first - a); int fr = 1; while(i < 2*n && v[i].first < b) { if (!fr) { mp[hh] += (v[i].first - v[i-1].first); } fr = 0; int p = v[i].second; int hs = hsh(p); if (!W[p]) { W[p]=1; hh += hs; hh %= 1000300079; } else { W[p]=0; hh -= hs; hh %= 1000300079; } i++; } mp[hh] += (b - v[i-1].first); int mx = 0; for(map<int,int>::iterator it = mp.begin(); it != mp.end(); ++it) { mx = max(mx, it ->second); } return mx; } int main() { scanf("%d%d%d",&n,&X,&Y); vx.resize(2*n); vy.resize(2*n); pts.resize(2*n); int x1,y1,x2,y2; int x00,x01,y00,y01; for (int i=0;i<n;i++) { scanf("%d%d%d%d",&x1,&y1,&x2,&y2); vx[2*i]=make_pair(x1,i); vx[2*i+1]=make_pair(x2,i); vy[2*i]=make_pair(y1,i); vy[2*i+1]=make_pair(y2,i); pts[2*i]=make_pair(x1,y1); pts[2*i+1]=make_pair(x2,y2); if (i==0) { x00 = x1; x01 = x2; y00 = y1; y01 = y2; } } if (x00 > x01) swap(x00,x01); if (y00 > y01) swap(y00,y01); for (int i=0;i<2*n;i++) { vx[i].first -= x00; if (vx[i].first < 0) vx[i].first += X; vy[i].first -= y00; if (vy[i].first < 0) vy[i].first += Y; } x01 -= x00; y01 -= y00; sort(vx.begin(), vx.end()); sort(vy.begin(), vy.end()); int xx = max(gm(vx, 0, x01),gm(vx, x01, X)); int yy = max(gm(vy, 0, y01),gm(vy, y01, Y)); //cout << xx << " " << yy << endl; printf("%lld\n",(LL)xx*yy); 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 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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | #include <iostream> #include <vector> #include <cstdio> #include <algorithm> #include <map> using namespace std; typedef long long LL; vector<pair<int, int> > vx; vector<pair<int, int> > vy; vector<pair<int, int> > pts; int n, X ,Y; map<int, int> mp; int W[1000005]; int hsh(int i) { return (i*i + pts[i].first * 1000300031 * (pts[i].second))%1000300057; } int gm(vector<pair<int, int> >& v, int a, int b) { mp.clear(); std::fill(W, W+1000000, 0); int hh = 0; int i=0; while (i < 2*n && v[i].first < a) i++; const int pp = i; int jj=i; while (v[jj].first == a) { int p = v[jj].second; int hs = hsh(p); if (!W[p]) { W[p]=1; hh += hs; hh %= 1000300079; } jj++; } mp[hh] = (v[i].first - a); int fr = 1; while(i < 2*n && v[i].first < b) { if (!fr) { mp[hh] += (v[i].first - v[i-1].first); } fr = 0; int p = v[i].second; int hs = hsh(p); if (!W[p]) { W[p]=1; hh += hs; hh %= 1000300079; } else { W[p]=0; hh -= hs; hh %= 1000300079; } i++; } mp[hh] += (b - v[i-1].first); int mx = 0; for(map<int,int>::iterator it = mp.begin(); it != mp.end(); ++it) { mx = max(mx, it ->second); } return mx; } int main() { scanf("%d%d%d",&n,&X,&Y); vx.resize(2*n); vy.resize(2*n); pts.resize(2*n); int x1,y1,x2,y2; int x00,x01,y00,y01; for (int i=0;i<n;i++) { scanf("%d%d%d%d",&x1,&y1,&x2,&y2); vx[2*i]=make_pair(x1,i); vx[2*i+1]=make_pair(x2,i); vy[2*i]=make_pair(y1,i); vy[2*i+1]=make_pair(y2,i); pts[2*i]=make_pair(x1,y1); pts[2*i+1]=make_pair(x2,y2); if (i==0) { x00 = x1; x01 = x2; y00 = y1; y01 = y2; } } if (x00 > x01) swap(x00,x01); if (y00 > y01) swap(y00,y01); for (int i=0;i<2*n;i++) { vx[i].first -= x00; if (vx[i].first < 0) vx[i].first += X; vy[i].first -= y00; if (vy[i].first < 0) vy[i].first += Y; } x01 -= x00; y01 -= y00; sort(vx.begin(), vx.end()); sort(vy.begin(), vy.end()); int xx = max(gm(vx, 0, x01),gm(vx, x01, X)); int yy = max(gm(vy, 0, y01),gm(vy, y01, Y)); //cout << xx << " " << yy << endl; printf("%lld\n",(LL)xx*yy); return 0; } |