#include #define rep(i,a,b) for(int i=a;i=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; templatebool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } templatebool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; } //--------------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )  Welcome to My Coding Space!      ( ´_ゝ`) /  ⌒i @hamayanhamayan0     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ struct MergedRect { map Points; ll area = 0; MergedRect() { Points[0] = infl; Points[infl] = 0; } /// /// (0,0)が左下で(x,y)が右上の四角形を追加 /// void add(ll x, ll y) { auto ite = Points.lower_bound(x); if (y <= ite->second) return; while (true) { auto pre = *prev(Points.lower_bound(x)); if (y < pre.second) break; Points.erase(pre.first); ll dx = pre.first - prev(Points.lower_bound(pre.first))->first; ll dy = pre.second - Points.lower_bound(pre.first)->second; area -= dx * dy; } area += (x - prev(Points.lower_bound(x))->first) * (y - Points.lower_bound(x)->second); Points[x] = y; } }; int N; MergedRect MR[4]; //--------------------------------------------------------------------------------------------------- void _main() { cin >> N; ll pre = 0; rep(i, 0, N) { int X1, Y1, X2, Y2; cin >> X1 >> Y1 >> X2 >> Y2; MR[0].add(-X1, -Y1); MR[1].add(-X1, Y2); MR[2].add(X2, -Y1); MR[3].add(X2, Y2); ll tot = MR[0].area + MR[1].area + MR[2].area + MR[3].area; printf("%lld\n", tot - pre); pre = tot; } }