#include <bits/stdc++.h> #define st first #define nd second #define pb push_back #define mp make_pair #define boost ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define F(i,k,n) for(int i = k ; i < n ; ++i) #define sz(x) (int)x.size() #define var(x) #x << " " << x #define all(v) (v).begin(), (v).end() const bool debug = 0; #define deb if(debug) using namespace std; typedef long long LL; typedef long double LD; typedef pair<int,int> PII; typedef pair<int,LL> PIL; typedef pair<LL,int> PLI; typedef pair<LL,LL> PLL; typedef vector<int> VI; typedef vector<PII> VII; typedef vector<LL> VLL; const int INF=1e9+7,N=5e5+7; LL a,b,c,d,n,m,k,wyn=0,X,Y,max_szer=0,max_wys=0; vector<pair<PLL,PLL> > points; vector<pair<LL,PLL> > pion,poziom; vector<LL> id; int main() { boost; cin >> n >> X >> Y; for(int i=0;i<n;i++){ cin >> a >> b >> c >> d; int x1=min(a,c),x2=max(a,c),y1=min(b,d),y2=max(b,d); points.pb({{x1,y1},{x2,y2}}); pion.pb({x1,{x2,i}}); pion.pb({x2,{x1,i}}); poziom.pb({y1,{y2,i}}); poziom.pb({y2,{y1,i}}); } pion.pb({0,{X,-1}}); pion.pb({X,{0,-1}}); poziom.pb({0,{Y,-1}}); poziom.pb({Y,{0,-1}}); sort(all(pion)); sort(all(poziom)); deb{for(int i=0;i<sz(pion);i++){ pair<LL,PLL> u=pion[i]; cout << "\tpion[ " << i << " ] = " << u.st << " { " << u.nd.st << " , " << u.nd.nd << " };"; if(u.nd.st<u.st) cout << " KONIEC"; cout << "\n"; } cout << "\n\n"; for(int i=0;i<sz(poziom);i++){ pair<LL,PLL> u=poziom[i]; cout << "\tpoziom[ " << i << " ] = " << u.st << " { " << u.nd.st << " , " << u.nd.nd << " };"; if(u.nd.st<u.st) cout << " KONIEC"; cout << "\n"; } cout << "\n\n";} id.resize(sz(poziom),0); stack<PLL> s; s.push({0,1}); LL last=0; for(int i=1;i<sz(poziom);i++){ pair<LL,PLL> u=poziom[i]; if(sz(s)==s.top().nd){ deb cout << "\tprzy " << i << " dodaje " << u.st-last << " do " << s.top().st << "\n"; id[s.top().st]+=u.st-last; }else{ id[i-1]+=u.st-last; deb cout << "\tprzy " << i << " dodaje " << u.st-last << " do id[ " << i-1 << " ];\n"; } if(u.nd.st<u.st){ s.pop(); }else{ s.push({i,s.size()+1}); } last=u.st; deb if(!s.empty())cout << "\t" << i << " :\t" << s.size() << "\t{ " << s.top().st << " , " << s.top().nd << " };\n"; } deb{for(int i=0;i<sz(poziom);i++) cout << "\tid[ " << i << " ] = " << id[i] << "\n"; cout << "\n\n";} for(int i=0;i<sz(id);i++){ max_wys=max(max_wys,id[i]); id[i]=0; } s.push({0,1}); last=0; for(int i=1;i<sz(pion);i++){ pair<LL,PLL> u=pion[i]; if(sz(s)==s.top().nd){ deb cout << "\tprzy " << i << " dodaje " << u.st-last << " do " << s.top().st << " " << last << "\n"; id[s.top().st]+=u.st-last; }else{ id[i-1]+=u.st-last; deb cout << "\tprzy " << i << " dodaje " << u.st-last << " do id[ " << i-1 << " ];\n"; } if(u.nd.st<u.st){ s.pop(); }else{ s.push({i,s.size()+1}); } last=u.st; deb if(!s.empty())cout << "\t" << i << " :\t" << s.size() << "\t{ " << s.top().st << " , " << s.top().nd << " };\n"; } deb for(int i=0;i<sz(pion);i++) cout << "\tid[ " << i << " ] = " << id[i] << "\n"; for(int i=0;i<sz(id);i++) max_szer=max(max_szer,id[i]); cout << max_wys*max_szer << "\n"; }
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 | #include <bits/stdc++.h> #define st first #define nd second #define pb push_back #define mp make_pair #define boost ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define F(i,k,n) for(int i = k ; i < n ; ++i) #define sz(x) (int)x.size() #define var(x) #x << " " << x #define all(v) (v).begin(), (v).end() const bool debug = 0; #define deb if(debug) using namespace std; typedef long long LL; typedef long double LD; typedef pair<int,int> PII; typedef pair<int,LL> PIL; typedef pair<LL,int> PLI; typedef pair<LL,LL> PLL; typedef vector<int> VI; typedef vector<PII> VII; typedef vector<LL> VLL; const int INF=1e9+7,N=5e5+7; LL a,b,c,d,n,m,k,wyn=0,X,Y,max_szer=0,max_wys=0; vector<pair<PLL,PLL> > points; vector<pair<LL,PLL> > pion,poziom; vector<LL> id; int main() { boost; cin >> n >> X >> Y; for(int i=0;i<n;i++){ cin >> a >> b >> c >> d; int x1=min(a,c),x2=max(a,c),y1=min(b,d),y2=max(b,d); points.pb({{x1,y1},{x2,y2}}); pion.pb({x1,{x2,i}}); pion.pb({x2,{x1,i}}); poziom.pb({y1,{y2,i}}); poziom.pb({y2,{y1,i}}); } pion.pb({0,{X,-1}}); pion.pb({X,{0,-1}}); poziom.pb({0,{Y,-1}}); poziom.pb({Y,{0,-1}}); sort(all(pion)); sort(all(poziom)); deb{for(int i=0;i<sz(pion);i++){ pair<LL,PLL> u=pion[i]; cout << "\tpion[ " << i << " ] = " << u.st << " { " << u.nd.st << " , " << u.nd.nd << " };"; if(u.nd.st<u.st) cout << " KONIEC"; cout << "\n"; } cout << "\n\n"; for(int i=0;i<sz(poziom);i++){ pair<LL,PLL> u=poziom[i]; cout << "\tpoziom[ " << i << " ] = " << u.st << " { " << u.nd.st << " , " << u.nd.nd << " };"; if(u.nd.st<u.st) cout << " KONIEC"; cout << "\n"; } cout << "\n\n";} id.resize(sz(poziom),0); stack<PLL> s; s.push({0,1}); LL last=0; for(int i=1;i<sz(poziom);i++){ pair<LL,PLL> u=poziom[i]; if(sz(s)==s.top().nd){ deb cout << "\tprzy " << i << " dodaje " << u.st-last << " do " << s.top().st << "\n"; id[s.top().st]+=u.st-last; }else{ id[i-1]+=u.st-last; deb cout << "\tprzy " << i << " dodaje " << u.st-last << " do id[ " << i-1 << " ];\n"; } if(u.nd.st<u.st){ s.pop(); }else{ s.push({i,s.size()+1}); } last=u.st; deb if(!s.empty())cout << "\t" << i << " :\t" << s.size() << "\t{ " << s.top().st << " , " << s.top().nd << " };\n"; } deb{for(int i=0;i<sz(poziom);i++) cout << "\tid[ " << i << " ] = " << id[i] << "\n"; cout << "\n\n";} for(int i=0;i<sz(id);i++){ max_wys=max(max_wys,id[i]); id[i]=0; } s.push({0,1}); last=0; for(int i=1;i<sz(pion);i++){ pair<LL,PLL> u=pion[i]; if(sz(s)==s.top().nd){ deb cout << "\tprzy " << i << " dodaje " << u.st-last << " do " << s.top().st << " " << last << "\n"; id[s.top().st]+=u.st-last; }else{ id[i-1]+=u.st-last; deb cout << "\tprzy " << i << " dodaje " << u.st-last << " do id[ " << i-1 << " ];\n"; } if(u.nd.st<u.st){ s.pop(); }else{ s.push({i,s.size()+1}); } last=u.st; deb if(!s.empty())cout << "\t" << i << " :\t" << s.size() << "\t{ " << s.top().st << " , " << s.top().nd << " };\n"; } deb for(int i=0;i<sz(pion);i++) cout << "\tid[ " << i << " ] = " << id[i] << "\n"; for(int i=0;i<sz(id);i++) max_szer=max(max_szer,id[i]); cout << max_wys*max_szer << "\n"; } |