結果

問題 No.3709 Unknown Treasure
コンテスト
ユーザー kuronosu1024
提出日時 2026-09-11 23:19:34
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 1,924 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,262 ms
コンパイル使用メモリ 344,164 KB
実行使用メモリ 47,616 KB
最終ジャッジ日時 2026-09-11 23:21:34
合計ジャッジ時間 24,289 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34 TLE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#ifndef INCLUDED_MAIN
#define INCLUDED_MAIN

#include __FILE__

using namespace nskr;


struct segment_tree {
    int n;
    vector<int> node;
    segment_tree(int n) : n(n), node(n<<1, 0) {} // 初期値が0になりました
    // i番目の要素そのものにアクセスできる機能をつけました
    int operator[](int i) { return node[i + n]; } 
    void set(int i, int x) {
        node[i += n] = x;
        while (i >>= 1) node[i] = node[i<<1|0] + node[i<<1|1]; // 和になりました
    }
    int fold(int l, int r) {
        int res = 0; // 初期値が0になりました
        for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) res = res + node[l++]; // 和になりました
            if (r & 1) res = node[--r] + res; // 和になりました
        }
        return res;
    }
};

int main(void){
    ll h, w; cin >> h >> w;
    ll n; cin >> n;
    vector<segment_tree> s(h,segment_tree(w));
    int i,j;
    rep(i,h) rep(j,w) s[i].set(j,1);

    set<pair<pair<int,int>,pair<int,int>>> q;
    for(;n--;){
        int a,b,c,d; cin >> a >> b >> c >> d;
        a--;b--;c--;d--;
        if(q.count({{a,b},{c,d}})) continue;
        q.insert({{a,b},{c,d}});
        
        for(int i=a; i<=c; i++){
            int u = s[i].fold(b,d+1);
            if(u == 0) continue;
            for(int j=b; j<=d; j++){
                s[i].set(j,0);
            }
        }
    }

    int ans = 0;
    rep(i,h){
        ans += s[i].fold(0,w);
    }
    cout << ans << "\n";
}

#else
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld=  long double;
#define rep(i,n) for(i=0;i<(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

namespace nskr{}

int randint(int a, int b){
    static mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> dist(a,b);
    return dist(gen);
}


#endif
0