//~ while (clock()<=69*CLOCKS_PER_SEC) //~ #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("O3") //~ #pragma GCC optimize("Ofast") //~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //~ #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; using ll=long long; using ld=long double; using pii=pair<int, int>; using pll=pair<ll, ll>; using vi=vector<int>; using vll=vector<ll>; template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<" = "<<h<<endl; } #ifdef LOCAL #define _upgrade ios_base::sync_with_stdio(0); #define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__); #else #define _upgrade ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define debug(...) 98; #define cerr if(0) cout #endif #define pb push_back #define mp make_pair #define all(x) x.begin(),x.end() #define sz(x) ((int)(x).size()) #define fi first #define se second #define erase_duplicates(x) sort(all(x)), (x).resize(distance((x).begin(), unique(all(x)))); #define watch(x) cout << (#x) << " is " << (x) << endl; #define pow2(x) ((x)*(x)) #define mod(x, m) ((((x) % (m)) + (m)) % (m)) #define max3(a, b, c) max(a, max(b, c)) #define min3(a, b, c) min(a, min(b, c)) #define REP(i, a, b) for(int i = a; i <= b; ++i) #define REPV(i, b, a) for(int i = b; i >= a; --i) const double m_pi = acos(-1.0); const int int_max = 0x3f3f3f3f; const int M7 = 1000*1000*1000+7; const int M9 = 1000*1000*1000+9; int n, x, y; vector<pii> prost; vector<ll> pola; vector<pii> prosty; vector<ll> polay; vector<pii> prostx; vector<ll> polax; vector<int> stref; int alive[1000009]; int otw[1000009]; int occ[1000009]; const int mmm = -100000000; void licz(){//cerr<<endl; for(int i=0;i<2*n+5;++i){ alive[i]=0; otw[i]=-1; occ[i]=0; } stref.clear(); int ooo=0; for(int i=0;i<sz(prost)-1;++i){//debug(prost[i].second); int rozm = prost[i+1].first - prost[i].first; if(prost[i].second > 0){ stref.pb(i); alive[prost[i].second]=1; ++ooo; } else if(prost[i].second < 0 && prost[i].second!=mmm){ alive[-prost[i].second]=0; --ooo; while(sz(stref)>0){ if(alive[prost[stref[sz(stref)-1]].second]==0)stref.pop_back(); else break; }//cerr<<"otw: "<<otw[ooo]<<endl; //if(sz(stref))debug(stref[sz(stref)-1]) if(otw[ooo]!=-1) if(sz(stref) == 0 || otw[ooo] >= stref[sz(stref)-1]){ rozm+= pola[otw[ooo]]; } } occ[i]=ooo; otw[ooo]=i;//debug(rozm); pola.pb(rozm); } } int main(){ _upgrade cout<<fixed<<setprecision(15); cin>>n>>x>>y; for(int i=1;i<=n;++i){ int x1, y1, x2, y2; cin>>x1>>y1>>x2>>y2; if(x1>x2)swap(x1, x2); if(y1>y2)swap(y1, y2); prosty.push_back({x1, i}); prosty.push_back({x2, -i}); prostx.push_back({y1, i}); prostx.push_back({y2, -i}); } prosty.pb({0, mmm}); prosty.pb({x, 0}); prostx.pb({0, mmm}); prostx.pb({y, 0}); sort(all(prosty)); sort(all(prostx)); swap(prost, prosty); swap(pola, polay); licz(); swap(prost, prosty); swap(pola, polay); swap(prost, prostx); swap(pola, polax); licz(); swap(prost, prostx); swap(pola, polax); long long m1=-1; for(int i=0;i<sz(polay);++i){ m1=max(m1, polay[i]); } long long m2=-1; for(int i=0;i<sz(polax);++i){ m2=max(m2, polax[i]); } cout<<m1*m2<<endl; return 0; } /* __builtin_popcount count total set bits on a given integer (use __builtin_popcountll for long long). */
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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | //~ while (clock()<=69*CLOCKS_PER_SEC) //~ #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("O3") //~ #pragma GCC optimize("Ofast") //~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //~ #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; using ll=long long; using ld=long double; using pii=pair<int, int>; using pll=pair<ll, ll>; using vi=vector<int>; using vll=vector<ll>; template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<" = "<<h<<endl; } #ifdef LOCAL #define _upgrade ios_base::sync_with_stdio(0); #define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__); #else #define _upgrade ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define debug(...) 98; #define cerr if(0) cout #endif #define pb push_back #define mp make_pair #define all(x) x.begin(),x.end() #define sz(x) ((int)(x).size()) #define fi first #define se second #define erase_duplicates(x) sort(all(x)), (x).resize(distance((x).begin(), unique(all(x)))); #define watch(x) cout << (#x) << " is " << (x) << endl; #define pow2(x) ((x)*(x)) #define mod(x, m) ((((x) % (m)) + (m)) % (m)) #define max3(a, b, c) max(a, max(b, c)) #define min3(a, b, c) min(a, min(b, c)) #define REP(i, a, b) for(int i = a; i <= b; ++i) #define REPV(i, b, a) for(int i = b; i >= a; --i) const double m_pi = acos(-1.0); const int int_max = 0x3f3f3f3f; const int M7 = 1000*1000*1000+7; const int M9 = 1000*1000*1000+9; int n, x, y; vector<pii> prost; vector<ll> pola; vector<pii> prosty; vector<ll> polay; vector<pii> prostx; vector<ll> polax; vector<int> stref; int alive[1000009]; int otw[1000009]; int occ[1000009]; const int mmm = -100000000; void licz(){//cerr<<endl; for(int i=0;i<2*n+5;++i){ alive[i]=0; otw[i]=-1; occ[i]=0; } stref.clear(); int ooo=0; for(int i=0;i<sz(prost)-1;++i){//debug(prost[i].second); int rozm = prost[i+1].first - prost[i].first; if(prost[i].second > 0){ stref.pb(i); alive[prost[i].second]=1; ++ooo; } else if(prost[i].second < 0 && prost[i].second!=mmm){ alive[-prost[i].second]=0; --ooo; while(sz(stref)>0){ if(alive[prost[stref[sz(stref)-1]].second]==0)stref.pop_back(); else break; }//cerr<<"otw: "<<otw[ooo]<<endl; //if(sz(stref))debug(stref[sz(stref)-1]) if(otw[ooo]!=-1) if(sz(stref) == 0 || otw[ooo] >= stref[sz(stref)-1]){ rozm+= pola[otw[ooo]]; } } occ[i]=ooo; otw[ooo]=i;//debug(rozm); pola.pb(rozm); } } int main(){ _upgrade cout<<fixed<<setprecision(15); cin>>n>>x>>y; for(int i=1;i<=n;++i){ int x1, y1, x2, y2; cin>>x1>>y1>>x2>>y2; if(x1>x2)swap(x1, x2); if(y1>y2)swap(y1, y2); prosty.push_back({x1, i}); prosty.push_back({x2, -i}); prostx.push_back({y1, i}); prostx.push_back({y2, -i}); } prosty.pb({0, mmm}); prosty.pb({x, 0}); prostx.pb({0, mmm}); prostx.pb({y, 0}); sort(all(prosty)); sort(all(prostx)); swap(prost, prosty); swap(pola, polay); licz(); swap(prost, prosty); swap(pola, polay); swap(prost, prostx); swap(pola, polax); licz(); swap(prost, prostx); swap(pola, polax); long long m1=-1; for(int i=0;i<sz(polay);++i){ m1=max(m1, polay[i]); } long long m2=-1; for(int i=0;i<sz(polax);++i){ m2=max(m2, polax[i]); } cout<<m1*m2<<endl; return 0; } /* __builtin_popcount count total set bits on a given integer (use __builtin_popcountll for long long). */ |