結果

問題 No.2055 12x34...
ユーザー 👑 H20H20
提出日時 2022-08-30 16:46:32
言語 Rust
(1.77.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 2,754 bytes
コンパイル時間 3,455 ms
コンパイル使用メモリ 171,136 KB
実行使用メモリ 16,488 KB
最終ジャッジ日時 2024-04-25 01:36:45
合計ジャッジ時間 6,955 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 7 ms
5,376 KB
testcase_03 AC 15 ms
5,376 KB
testcase_04 AC 19 ms
5,376 KB
testcase_05 AC 21 ms
5,376 KB
testcase_06 AC 19 ms
5,376 KB
testcase_07 AC 16 ms
5,376 KB
testcase_08 AC 11 ms
5,376 KB
testcase_09 AC 23 ms
5,376 KB
testcase_10 AC 24 ms
5,376 KB
testcase_11 AC 11 ms
5,376 KB
testcase_12 AC 30 ms
9,404 KB
testcase_13 AC 54 ms
16,432 KB
testcase_14 AC 23 ms
9,264 KB
testcase_15 AC 24 ms
9,144 KB
testcase_16 AC 56 ms
16,488 KB
testcase_17 AC 16 ms
5,376 KB
testcase_18 AC 29 ms
5,376 KB
testcase_19 AC 7 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 8 ms
5,376 KB
testcase_22 AC 39 ms
6,884 KB
testcase_23 AC 42 ms
10,148 KB
testcase_24 AC 40 ms
10,148 KB
testcase_25 AC 40 ms
10,148 KB
testcase_26 AC 38 ms
10,144 KB
testcase_27 AC 39 ms
10,148 KB
testcase_28 AC 41 ms
10,272 KB
testcase_29 AC 40 ms
10,276 KB
testcase_30 AC 41 ms
10,152 KB
testcase_31 AC 41 ms
10,052 KB
testcase_32 AC 41 ms
10,048 KB
testcase_33 AC 25 ms
5,376 KB
testcase_34 AC 25 ms
5,376 KB
testcase_35 AC 26 ms
5,376 KB
testcase_36 AC 26 ms
5,376 KB
testcase_37 AC 26 ms
5,376 KB
testcase_38 AC 26 ms
5,376 KB
testcase_39 AC 27 ms
5,376 KB
testcase_40 AC 25 ms
5,376 KB
testcase_41 AC 26 ms
5,376 KB
testcase_42 AC 26 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::HashMap;
//USE https://mirrorless-camera.info/column/14417.html

macro_rules! input {
    ($($r:tt)*) => {
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(std::io::stdin()));
        let mut next = move |is_word: bool| -> String{
            if is_word {
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            } else {
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c| c == &'\n')
                    .take_while(|c| c != &'\n')
                    .collect()
            }
        };
        input_inner!{next, $($r)*};
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

    ($next:expr, [ $t:tt ; all ]) => { {
            let mut str = $next(false);
            str.split_whitespace().map(|it| it.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };

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

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

    ($next:expr, lines) => {
        {
            let mut vec = Vec::new();
            let mut str = $next(false);
            while str != "" {
                vec.push(str);
                str = $next(false);
            }
            vec
        }
    };

    ($next:expr, line) => {
        $next(false)
    };

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

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

fn main() {
    input! {
        n : usize,
        a : [usize; n]
    }
    let mut hm: HashMap<usize, usize> = HashMap::new();
    let mut ans = 0; 
    for a in a{
        *hm.entry(a).or_default() = (*hm.entry(a).or_default() + *hm.entry(a-1).or_default() +1)%998244353;
        ans = (ans+hm[&(a-1)])%998244353;
    }
    println!("{}", ans);
}
0