提出 #72163798


ソースコード 拡げる

#![allow(unused)]

use std::collections::BTreeSet;

use proconio::input;

fn main() {
    input! {
        n: usize,
        lr: [(usize, usize); n],
    }

    let mut segs = BTreeSet::new();
    for (l, r) in lr {
        let mut new_l = l;
        let mut new_r = r;
        while let Some(&(b, a)) = segs.range((new_l, 0)..).next() {
            if new_r < a {
                break;
            }
            segs.remove(&(b, a));
            new_l = new_l.min(a);
            new_r = new_r.max(b);
        }

        segs.insert((new_r, new_l));
    }

    let mut ans = segs.iter().map(|&(r, l)| (l, r)).collect::<Vec<_>>();
    ans.sort();
    for (l, r) in ans {
        println!("{} {}", l, r);
    }
}

fn join<T: ToString>(arr: &[T], sep: &str) -> String {
    arr.iter()
        .map(|x| x.to_string())
        .collect::<Vec<String>>()
        .join(sep)
}

提出情報

提出日時
問題 D - Union of Interval
ユーザ amoshuangyc
言語 Rust (rustc 1.89.0)
得点 400
コード長 912 Byte
結果 AC
実行時間 85 ms
メモリ 6420 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 2
AC × 24
セット名 テストケース
Sample sample_01.txt, sample_02.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, sample_01.txt, sample_02.txt
ケース名 結果 実行時間 メモリ
random_01.txt AC 22 ms 5112 KiB
random_02.txt AC 11 ms 2812 KiB
random_03.txt AC 61 ms 5008 KiB
random_04.txt AC 23 ms 4736 KiB
random_05.txt AC 41 ms 5016 KiB
random_06.txt AC 60 ms 5004 KiB
random_07.txt AC 24 ms 5008 KiB
random_08.txt AC 19 ms 3276 KiB
random_09.txt AC 62 ms 5036 KiB
random_10.txt AC 21 ms 4680 KiB
random_11.txt AC 17 ms 5104 KiB
random_12.txt AC 1 ms 1952 KiB
random_13.txt AC 49 ms 4204 KiB
random_14.txt AC 44 ms 4160 KiB
random_15.txt AC 27 ms 3364 KiB
random_16.txt AC 78 ms 5864 KiB
random_17.txt AC 71 ms 5852 KiB
random_18.txt AC 41 ms 4172 KiB
random_19.txt AC 85 ms 6420 KiB
random_20.txt AC 41 ms 4076 KiB
random_21.txt AC 40 ms 4560 KiB
random_22.txt AC 28 ms 3576 KiB
sample_01.txt AC 1 ms 1960 KiB
sample_02.txt AC 1 ms 2024 KiB