結果
| 問題 |
No.2708 Jewel holder
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-31 13:47:50 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 1,550 bytes |
| コンパイル時間 | 11,461 ms |
| コンパイル使用メモリ | 379,284 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-09-30 18:25:20 |
| 合計ジャッジ時間 | 12,312 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
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>());
}