結果
| 問題 | 
                            No.1074 増殖
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-06-06 01:32:28 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 56 ms / 2,000 ms | 
| コード長 | 1,604 bytes | 
| コンパイル時間 | 2,046 ms | 
| コンパイル使用メモリ | 205,168 KB | 
| 最終ジャッジ日時 | 2025-01-10 23:10:03 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 12 | 
ソースコード
#include <bits/stdc++.h>  // 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<Int, Int> mp;
    Plane() {
        mp[0] = INF;
        mp[INF] = 0;
    }
    Int area(std::map<Int, Int>::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_point(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<Plane> ps(4);
    REP(i, n) {
        Int xa, ya, xb, yb;
        std::cin >> xa >> ya >> xb >> yb;
        Int ans = 0;
        ans += ps[0].add_point(xb, yb);
        ans += ps[1].add_point(-xa, yb);
        ans += ps[2].add_point(xb, -ya);
        ans += ps[3].add_point(-xa, -ya);
        std::cout << ans << "\n";
    }
}