結果
| 問題 | No.2646 Cycle Maze |
| ユーザー |
shinnshinn
|
| 提出日時 | 2024-02-12 16:46:46 |
| 言語 | Rust (1.94.0 + proconio + num + itertools) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,628 bytes |
| 記録 | |
| コンパイル時間 | 3,664 ms |
| コンパイル使用メモリ | 199,724 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-15 20:18:45 |
| 合計ジャッジ時間 | 8,545 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 43 WA * 8 |
コンパイルメッセージ
warning: unused import: `std::collections::VecDeque` --> src/main.rs:1:5 | 1 | use std::collections::VecDeque; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default
ソースコード
use std::collections::VecDeque;
use itertools::Itertools;
use proconio::{marker::{Bytes, Usize1}, *};
const DIFF_4: [(usize, usize); 4] = [(0, 1), (0, !0), (1, 0), (!0, 0)];
fn grid_move_iter<'a>(i: usize, j: usize, h: usize, w: usize, d: &'a[(usize, usize)]) -> impl Iterator<Item = (usize, usize)> + 'a {
d.iter().filter_map(move |&(di, dj)| {
let ni = i.wrapping_add(di);
let nj = j.wrapping_add(dj);
if ni < h && nj < w {
Some((ni, nj))
} else {
None
}
})
}
fn main() {
input! {
h: usize,
w: usize,
t: usize,
ss: (Usize1, Usize1),
g: (Usize1, Usize1),
ts: [Bytes; h],
}
let mut s = ts.iter().map(|b| b.iter().map(|&b| (b - b'0') as usize).collect_vec()).collect_vec();
let init = s.clone();
let mut ok = vec![vec![false; w]; h];
ok[ss.0][ss.1] = true;
for _ in 0..t {
for i in 0..h {
for j in 0..w {
if s[i][j] == 0 {
s[i][j] = init[i][j];
} else {
s[i][j] -= 1;
}
}
}
let mut nok = ok.clone();
for i in 0..h {
for j in 0..w {
if !ok[i][j] { continue; }
for (ni, nj) in grid_move_iter(i, j, h, w, &DIFF_4) {
if s[ni][nj] == 0 { continue; }
nok[ni][nj] = ok[i][j];
}
}
}
ok = nok;
if ok[g.0][g.1] {
println!("Yes");
return;
}
}
println!("No");
}
shinnshinn