#include // clang-format off using Int = long long; #define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++) #define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__) struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io; #ifndef dump #define dump(...) #endif // clang-format on /** * author: knshnb * created: Fri Jun 5 22:30:45 JST 2020 **/ const Int INF = 1e9; struct Plane { std::map mp; Plane() { mp[0] = INF; mp[INF] = 0; } Int area(std::map::iterator it) { Int dx = it->first - std::prev(it)->first; Int dy = it->second - std::next(it)->second; return dx * dy; } // return difference of area Int add(Int x, Int y) { if (mp.lower_bound(x)->second >= y) return 0; Int dif = 0; while (1) { auto it = std::prev(mp.upper_bound(x)); if (it->second > y) break; dif -= area(it); mp.erase(it); } mp[x] = y; dif += area(mp.find(x)); return dif; } }; signed main() { Int n; std::cin >> n; std::vector ps(4); REP(i, n) { Int xa, ya, xb, yb; std::cin >> xa >> ya >> xb >> yb; Int ans = 0; ans += ps[0].add(xb, yb); ans += ps[1].add(-xa, yb); ans += ps[2].add(xb, -ya); ans += ps[3].add(-xa, -ya); std::cout << ans << "\n"; } }