結果

問題 No.945 YKC饅頭
ユーザー koba-e964koba-e964
提出日時 2019-12-18 00:48:02
言語 Rust
(1.77.0)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 2,790 bytes
コンパイル時間 3,153 ms
コンパイル使用メモリ 170,452 KB
実行使用メモリ 18,880 KB
最終ジャッジ日時 2023-09-18 11:10:00
合計ジャッジ時間 12,837 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 9 ms
4,376 KB
testcase_32 AC 14 ms
4,376 KB
testcase_33 AC 34 ms
6,136 KB
testcase_34 AC 64 ms
10,824 KB
testcase_35 AC 102 ms
15,996 KB
testcase_36 AC 77 ms
12,792 KB
testcase_37 AC 73 ms
11,552 KB
testcase_38 AC 66 ms
10,460 KB
testcase_39 AC 21 ms
4,380 KB
testcase_40 AC 25 ms
5,044 KB
testcase_41 AC 13 ms
4,376 KB
testcase_42 AC 89 ms
14,140 KB
testcase_43 AC 67 ms
11,548 KB
testcase_44 AC 80 ms
12,564 KB
testcase_45 AC 100 ms
15,508 KB
testcase_46 AC 8 ms
4,376 KB
testcase_47 AC 63 ms
10,404 KB
testcase_48 AC 15 ms
4,376 KB
testcase_49 AC 32 ms
5,808 KB
testcase_50 AC 104 ms
16,188 KB
testcase_51 AC 122 ms
18,820 KB
testcase_52 AC 122 ms
18,828 KB
testcase_53 AC 121 ms
18,812 KB
testcase_54 AC 123 ms
18,880 KB
testcase_55 AC 122 ms
18,864 KB
testcase_56 AC 19 ms
5,580 KB
testcase_57 AC 10 ms
4,812 KB
testcase_58 AC 131 ms
14,068 KB
testcase_59 AC 143 ms
16,336 KB
testcase_60 AC 74 ms
8,700 KB
testcase_61 AC 131 ms
14,788 KB
testcase_62 AC 128 ms
14,332 KB
testcase_63 AC 11 ms
4,928 KB
testcase_64 AC 78 ms
9,196 KB
testcase_65 AC 67 ms
8,196 KB
testcase_66 AC 64 ms
7,928 KB
testcase_67 AC 103 ms
11,732 KB
testcase_68 AC 76 ms
8,872 KB
testcase_69 AC 33 ms
6,048 KB
testcase_70 AC 40 ms
6,348 KB
testcase_71 AC 41 ms
6,444 KB
testcase_72 AC 90 ms
10,172 KB
testcase_73 AC 139 ms
15,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        lrt: [(usize1, usize, chars)],
    }
    let mut unocc = (0..n).collect::<BTreeSet<_>>();
    let mut cnt = [0; 3];
    for (l, r, t) in lrt {
        let idx = match t[0] {
            'Y' => 0,
            'K' => 1,
            'C' => 2,
            _ => unreachable!(),
        };
        let mut placed = vec![];
        for &e in unocc.range(l..r) {
            placed.push(e);
            cnt[idx] += 1;
        }
        for e in placed {
            unocc.remove(&e);
        }
    }
    puts!("{} {} {}\n", cnt[0], cnt[1], cnt[2]);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}
0