結果

問題 No.2708 Jewel holder
ユーザー nomeaningnomeaning
提出日時 2024-03-31 13:47:50
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,550 bytes
コンパイル時間 7,886 ms
コンパイル使用メモリ 166,044 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-31 13:48:00
合計ジャッジ時間 1,659 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,548 KB
testcase_01 AC 1 ms
6,548 KB
testcase_02 AC 1 ms
6,548 KB
testcase_03 AC 1 ms
6,548 KB
testcase_04 AC 1 ms
6,548 KB
testcase_05 AC 1 ms
6,548 KB
testcase_06 AC 1 ms
6,548 KB
testcase_07 AC 1 ms
6,548 KB
testcase_08 AC 1 ms
6,548 KB
testcase_09 AC 1 ms
6,548 KB
testcase_10 AC 1 ms
6,548 KB
testcase_11 AC 1 ms
6,548 KB
testcase_12 AC 1 ms
6,548 KB
testcase_13 AC 1 ms
6,548 KB
testcase_14 AC 1 ms
6,548 KB
testcase_15 AC 1 ms
6,548 KB
testcase_16 AC 1 ms
6,548 KB
testcase_17 AC 1 ms
6,548 KB
testcase_18 AC 1 ms
6,548 KB
testcase_19 AC 1 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let stdin = std::io::stdin();
    let mut line = String::new();
    stdin.read_line(&mut line).unwrap();
    let h = line
        .split_whitespace()
        .next()
        .unwrap()
        .parse::<usize>()
        .unwrap();
    let mut map: Vec<Vec<u8>> = vec![vec![]; h];
    for i in 0..h {
        let mut line = String::new();
        stdin.read_line(&mut line).unwrap();
        map[i] = line.trim().as_bytes().to_vec();
    }
    let w = map[0].len();
    let mut result: Vec<Vec<Vec<i64>>> = vec![vec![vec![0; w + h + 1]; w]; h];
    result[0][0][1] = 1;
    for i in 0..h {
        for j in 0..w {
            for current in 0..=w + h {
                if result[i][j][current] == 0 {
                    continue;
                }
                if j + 1 < w {
                    if map[i][j + 1] == b'o' {
                        result[i][j + 1][current + 1] += result[i][j][current];
                    } else if map[i][j + 1] == b'x' && current > 0 {
                        result[i][j + 1][current - 1] += result[i][j][current];
                    }
                }
                if i + 1 < h {
                    if map[i + 1][j] == b'o' {
                        result[i + 1][j][current + 1] += result[i][j][current];
                    } else if map[i + 1][j] == b'x' && current > 0 {
                        result[i + 1][j][current - 1] += result[i][j][current];
                    }
                }
            }
        }
    }
    println!("{}", result[h - 1][w - 1].iter().sum::<i64>());
}
0