結果

問題 No.3709 Unknown Treasure
コンテスト
ユーザー norioc
提出日時 2026-09-22 18:43:22
言語 Rust
(1.97.1 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 61 ms / 2,000 ms
+ 300µs
コード長 1,644 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,337 ms
コンパイル使用メモリ 201,584 KB
実行使用メモリ 47,492 KB
最終ジャッジ日時 2026-09-22 18:43:30
合計ジャッジ時間 7,773 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge5_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#![allow(non_snake_case, unused_imports)]

use std::cmp::{min, max};
use std::collections::{BinaryHeap, Bound, HashMap, HashSet, VecDeque};
use std::hash::Hash;
use std::ops::RangeBounds;
use ac_library::{Additive, Min, Segtree};
use proconio::{input, marker::Usize1, marker::Chars};
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! d {
    ( $( $x:expr ),* $(,)? ) => {
        eprintln!(
            concat!( $( stringify!($x), "={:?} " ),* ),
            $( $x ),*
        );
    };
}

#[allow(dead_code)]
fn yn(b: bool) -> &'static str {
    if b { "Yes" } else { "No" }
}

fn imos2d(h: usize, w: usize, rects: &[(usize, usize, usize, usize, i64)]) -> Vec<Vec<i64>> {
    let mut imos = vec![vec![0; w+1]; h+1];
    for &(r1, c1, r2, c2, v) in rects {
        imos[r1][c1] += v;
        imos[r1][c2 + 1] -= v;
        imos[r2+1][c1] -= v;
        imos[r2+1][c2 + 1] += v;
    }

    for r in 0..h {
        for c in 1..w {
            imos[r][c] += imos[r][c-1];
        }
    }
    for r in 1..h {
        for c in 0..w {
            imos[r][c] += imos[r-1][c];
        }
    }

    imos.truncate(h);
    for row in &mut imos {
        row.truncate(w);
    }
    imos
}

fn main() {
    input! {
        H: usize,
        W: usize,
        N: usize,
        LRS: [(Usize1, Usize1, Usize1, Usize1); N],
    }

    let lrs = LRS.iter()
        .map(|&(r1, c1, r2, c2)| (r1, c1, r2, c2, 1))
        .collect_vec();

    let g = imos2d(H, W, &lrs);
    let mut ans = 0;
    for i in 0..H {
        for j in 0..W {
            if g[i][j] == 0 {
                ans += 1;
            }
        }
    }

    println!("{}", ans);
}
0