結果

問題 No.323 yuki国
ユーザー koba-e964koba-e964
提出日時 2021-11-10 22:26:24
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 2,246 bytes
コンパイル時間 14,538 ms
コンパイル使用メモリ 379,520 KB
実行使用メモリ 7,168 KB
最終ジャッジ日時 2024-05-01 11:02:53
合計ジャッジ時間 15,428 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 5 ms
6,944 KB
testcase_09 WA -
testcase_10 AC 1 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 1 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 5 ms
6,912 KB
testcase_15 WA -
testcase_16 AC 69 ms
7,168 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 40 ms
5,376 KB
testcase_20 WA -
testcase_21 AC 64 ms
7,040 KB
testcase_22 WA -
testcase_23 AC 15 ms
7,168 KB
testcase_24 WA -
testcase_25 AC 69 ms
7,168 KB
testcase_26 WA -
testcase_27 AC 6 ms
6,912 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 1 ms
5,376 KB
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::*;
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes.by_ref().map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

macro_rules! read_value {
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

fn main() {
    input! {
        h: usize, w: usize,
        a: usize1, sx: usize, sy: usize,
        b: usize1, gx: usize, gy: usize,
        c: [chars; h],
    }
    const W: usize = 2000;
    let mut vis = vec![vec![vec![false; W]; w]; h];
    let mut que = VecDeque::new();
    let dxy = [(0i32, 1i32), (1, 0), (-1, 0), (0, -1)];
    que.push_back((sx, sy, a));
    while let Some((x, y, k)) = que.pop_front() {
        if vis[x][y][k] { continue; }
        vis[x][y][k] = true;
        for &(dx, dy) in &dxy {
            let nx = (x as i32 + dx) as usize;
            let ny = (y as i32 + dy) as usize;
            if nx >= h || ny >= w { continue; }
            if c[nx][ny] == '#' {
                if k + 1 < W {
                    if vis[nx][ny][k + 1] { continue; }
                    que.push_back((nx, ny, k + 1));
                }
            } else {
                if k > 0 {
                    if vis[nx][ny][k - 1] { continue; }
                    que.push_back((nx, ny, k - 1));
                }
            }
        }
    }
    println!("{}", if vis[gx][gy][b] { "Yes" } else { "No" });
}
0