#include #include #include #include using namespace std; int N; set >S[4]; main() { for(int i=0;i<4;i++) { S[i].insert(make_pair(0,1e5)); S[i].insert(make_pair(1e5,0)); } cin>>N; for(;N--;) { int Xa,Ya,Xb,Yb; cin>>Xa>>Ya>>Xb>>Yb; int X[4]={Xb,-Xa,-Xa,Xb}; int Y[4]={Yb,Yb,-Ya,-Ya}; int ans=0; for(int i=0;i<4;i++) { set >::iterator it=S[i].upper_bound(make_pair(X[i],-1)); if(it->second>Y[i])continue; int py=it->second; it--; int pre=X[i]; while(true){ ans+=(Y[i]-py)*(pre-it->first); if(it->second>Y[i])break; py=it->second; pre=it->first; it=S[i].erase(it); it--; } S[i].insert(make_pair(X[i],Y[i])); } cout<