#include #include using namespace std; #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define Rreps(i,n,e) for(int i = n - 1; i >= e; --i) #define Rrep(i,n) Rreps(i,n,0) #define ALL(a) a.begin(), a.end() #define fi first #define se second typedef long long ll; typedef vector vec; typedef vector mat; ll N,M,H,W,Q,K,A,B; string S; const ll MOD = 998244353; //const ll MOD = (1e+9) + 7; typedef pair P; const ll INF = (1LL<<62); void solve(vec &res, vec x, vec y){ const int max_x = 20005; set

pts; pts.emplace(0, N); pts.emplace(max_x, N + 1); x.push_back(0); x.push_back(max_x); y.push_back(max_x); y.push_back(0); rep(i,N){ auto ite = pts.lower_bound(P(x[i] + 1, -1)); if(y[ite->se] >= y[i]) continue; bool flag = false, one = true; while(y[ite->se] <= y[i]){ ll last_id = ite->se; --ite; if(x[ite->se] == x[i] && y[ite->se] >= y[i]) { flag = true; break; } res[i] += (min(x[i], x[last_id]) - x[ite->se]) * (y[i] - y[last_id]); one ? one = false : pts.erase(P(x[last_id], last_id)); } if(!flag) pts.emplace(x[i], i); } } int main() { cin>>N; mat x(2, vec(N)), y(2, vec(N)); vec res(N, 0); rep(i,N){ rep(j,2) cin>>x[j][i]>>y[j][i]; x[0][i] *= -1; y[0][i] *= -1; } rep(i,2) rep(j,2) { solve(res, x[i], y[j]); /* rep(k,N){ cout<