結果

問題 No.2867 NOT FOUND 404 Again
ユーザー maguroflymagurofly
提出日時 2024-08-30 22:10:44
言語 Rust
(1.77.0)
結果
AC  
実行時間 211 ms / 3,000 ms
コード長 1,507 bytes
コンパイル時間 13,251 ms
コンパイル使用メモリ 402,244 KB
実行使用メモリ 14,796 KB
最終ジャッジ日時 2024-08-30 22:11:01
合計ジャッジ時間 16,867 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,820 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 161 ms
14,592 KB
testcase_04 AC 158 ms
14,620 KB
testcase_05 AC 159 ms
14,588 KB
testcase_06 AC 159 ms
14,612 KB
testcase_07 AC 159 ms
14,772 KB
testcase_08 AC 159 ms
14,656 KB
testcase_09 AC 158 ms
14,708 KB
testcase_10 AC 159 ms
14,508 KB
testcase_11 AC 159 ms
14,644 KB
testcase_12 AC 158 ms
14,604 KB
testcase_13 AC 157 ms
14,780 KB
testcase_14 AC 157 ms
14,556 KB
testcase_15 AC 161 ms
14,568 KB
testcase_16 AC 160 ms
14,796 KB
testcase_17 AC 159 ms
14,624 KB
testcase_18 AC 116 ms
14,568 KB
testcase_19 AC 211 ms
14,564 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable `N` should have a snake case name
 --> src/main.rs:7:9
  |
7 |         N: Chars,
  |         ^ help: convert the identifier to snake case: `n`
  |
  = note: `#[warn(non_snake_case)]` on by default

warning: variable `N` should have a snake case name
  --> src/main.rs:10:9
   |
10 |     let N = N.into_iter().map(|x| x.to_digit(10).unwrap() as usize ).collect::<Vec<_>>();
   |         ^ help: convert the identifier to snake case: `n`

ソースコード

diff #

use proconio::{input, marker::Chars};

const MOD: usize = 998244353;

fn main() {
    input! {
        N: Chars,
    }

    let N = N.into_iter().map(|x| x.to_digit(10).unwrap() as usize ).collect::<Vec<_>>();

    fn trans(state: usize, digit: usize) -> usize {
        match (state, digit) {
            (0, 4) => 1,
            (1, 0) => 2,
            (1, 4) => 1,
            (2, 4) => 3,
            _ => 0
        }
    }

    let mut eq = [0; 4];
    let mut lt = [0; 4];
    eq[0] = 1;
    for digit in N {
        let mut eq_next = [0; 4];
        let mut lt_next = [0; 4];
        
        // lt -> lt
        for d in 0 ..= 9 {
            for state in 0 .. 3 {
                let state_next = trans(state, d);
                lt_next[state_next] += lt[state];
                lt_next[state_next] %= MOD;
            }
        }
        // eq -> lt
        for d in 0 .. digit {
            for state in 0 .. 3 {
                let state_next = trans(state, d);
                lt_next[state_next] += eq[state];
                lt_next[state_next] %= MOD;
            }
        }
        // eq -> eq
        {
            let d = digit;
            for state in 0 .. 3 {
                let state_next = trans(state, d);
                eq_next[state_next] += eq[state];
                eq_next[state_next] %= MOD;
            }
        }
        eq = eq_next;
        lt = lt_next;
    }

    let ans = (eq[0] + eq[1] + eq[2] + lt[0] + lt[1] + lt[2] + MOD - 1) % MOD;
    println!("{ans}");
}
0