結果

問題 No.1588 Connection
ユーザー phsplsphspls
提出日時 2022-11-25 00:43:25
言語 Rust
(1.72.1)
結果
WA  
実行時間 -
コード長 1,362 bytes
コンパイル時間 856 ms
コンパイル使用メモリ 146,104 KB
実行使用メモリ 24,540 KB
平均クエリ数 526.03
最終ジャッジ日時 2023-07-24 17:36:24
合計ジャッジ時間 5,290 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,412 KB
testcase_01 WA -
testcase_02 AC 22 ms
24,072 KB
testcase_03 AC 22 ms
24,408 KB
testcase_04 AC 24 ms
23,544 KB
testcase_05 AC 23 ms
23,400 KB
testcase_06 AC 24 ms
24,072 KB
testcase_07 AC 24 ms
23,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 24 ms
23,820 KB
testcase_15 AC 25 ms
24,264 KB
testcase_16 AC 25 ms
23,664 KB
testcase_17 AC 24 ms
23,628 KB
testcase_18 AC 23 ms
23,604 KB
testcase_19 AC 25 ms
24,048 KB
testcase_20 AC 28 ms
23,640 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 69 ms
23,544 KB
testcase_26 AC 66 ms
23,412 KB
testcase_27 AC 41 ms
24,384 KB
testcase_28 AC 37 ms
24,288 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::VecDeque;


const INF: usize = 1usize << 60;
const DX: [isize; 4] = [-1, 1, 0, 0];
const DY: [isize; 4] = [0, 0, -1, 1];

fn main() {
    let mut nm = String::new();
    std::io::stdin().read_line(&mut nm).ok();
    let nm: Vec<usize> = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nm[0];
    let m = nm[1];

    let mut grid = vec![vec![INF; m]; n];
    let mut deque = VecDeque::new();
    deque.push_back((0usize, 0usize));
    while let Some((x, y)) = deque.pop_front() {
        if grid[x][y] < INF { continue; }
        println!("{} {}", x + 1, y + 1);
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let s = s.trim();
        if s == "Black" {
            grid[x][y] = 1;
            for dir in 0..4 {
                let nx = x as isize + DX[dir];
                let ny = y as isize + DY[dir];
                if nx >= 0 && ny >= 0 && nx < n as isize && ny < m as isize {
                    let nx = nx as usize;
                    let ny = ny as usize;
                    if grid[nx][ny] < INF { continue; }
                    deque.push_back((nx, ny));
                }
            }
        } else {
            grid[x][y] = 0;
        }
    }
    if grid[n-1][m-1] == INF {
        println!("No");
    } else {
        println!("Yes");
    }
}
0