#include <iostream> #include <vector> #include <map> #include <set> #include <algorithm> #include <string> using namespace std; typedef long long int llint; struct point_t { int coord; int id; inline bool operator<(const point_t& o) const { if(coord!=o.coord)return coord<o.coord; return id<o.id; } }; int calc(vector<point_t>& p,int M) { sort(p.begin(),p.end()); int new_psize=1; for(int i=1;i<(int)p.size();++i) if(p[new_psize-1].coord!=p[i].coord) p[new_psize++]=p[i]; p.resize(new_psize); const int ps=(int)p.size(); int res=0; for(int i=0;i<ps;++i) { int dist=p[(i+1)%ps].coord-p[i].coord; if(dist<0)dist+=M; if(dist>res)res=dist; } if(ps>=4) for(int i=0;i<ps;++i) { if(p[(i+1)%ps].id==p[(i+2)%ps].id) { int dist=p[(i+3)%ps].coord-p[i].coord; if(dist<0)dist+=M; int dist_dec=p[(i+2)%ps].coord-p[(i+1)%ps].coord; if(dist_dec<0)dist_dec+=M; dist-=dist_dec; if(dist>res)res=dist; } } return res; } /* 2 10 7 2 1 8 6 5 2 4 4 */ int main() { int n; scanf("%d",&n); int X,Y; scanf("%d %d",&X,&Y); vector<point_t> x; vector<point_t> y; for(int i=0;i<n;++i) { point_t p; p.id=i; scanf("%d",&p.coord); x.push_back(p); scanf("%d",&p.coord); y.push_back(p); scanf("%d",&p.coord); x.push_back(p); scanf("%d",&p.coord); y.push_back(p); } printf("%lld",(llint)calc(x,X)*(llint)calc(y,Y)); 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 | #include <iostream> #include <vector> #include <map> #include <set> #include <algorithm> #include <string> using namespace std; typedef long long int llint; struct point_t { int coord; int id; inline bool operator<(const point_t& o) const { if(coord!=o.coord)return coord<o.coord; return id<o.id; } }; int calc(vector<point_t>& p,int M) { sort(p.begin(),p.end()); int new_psize=1; for(int i=1;i<(int)p.size();++i) if(p[new_psize-1].coord!=p[i].coord) p[new_psize++]=p[i]; p.resize(new_psize); const int ps=(int)p.size(); int res=0; for(int i=0;i<ps;++i) { int dist=p[(i+1)%ps].coord-p[i].coord; if(dist<0)dist+=M; if(dist>res)res=dist; } if(ps>=4) for(int i=0;i<ps;++i) { if(p[(i+1)%ps].id==p[(i+2)%ps].id) { int dist=p[(i+3)%ps].coord-p[i].coord; if(dist<0)dist+=M; int dist_dec=p[(i+2)%ps].coord-p[(i+1)%ps].coord; if(dist_dec<0)dist_dec+=M; dist-=dist_dec; if(dist>res)res=dist; } } return res; } /* 2 10 7 2 1 8 6 5 2 4 4 */ int main() { int n; scanf("%d",&n); int X,Y; scanf("%d %d",&X,&Y); vector<point_t> x; vector<point_t> y; for(int i=0;i<n;++i) { point_t p; p.id=i; scanf("%d",&p.coord); x.push_back(p); scanf("%d",&p.coord); y.push_back(p); scanf("%d",&p.coord); x.push_back(p); scanf("%d",&p.coord); y.push_back(p); } printf("%lld",(llint)calc(x,X)*(llint)calc(y,Y)); return 0; } |