結果

問題 No.1588 Connection
ユーザー phsplsphspls
提出日時 2022-11-25 00:46:26
言語 Rust
(1.72.1)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 1,362 bytes
コンパイル時間 960 ms
コンパイル使用メモリ 144,256 KB
実行使用メモリ 24,456 KB
平均クエリ数 564.00
最終ジャッジ日時 2023-07-24 17:38:58
合計ジャッジ時間 4,338 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
24,216 KB
testcase_01 AC 21 ms
23,532 KB
testcase_02 AC 22 ms
24,228 KB
testcase_03 AC 21 ms
24,036 KB
testcase_04 AC 21 ms
24,312 KB
testcase_05 AC 22 ms
23,640 KB
testcase_06 AC 23 ms
23,628 KB
testcase_07 AC 23 ms
23,376 KB
testcase_08 AC 27 ms
24,456 KB
testcase_09 AC 25 ms
24,036 KB
testcase_10 AC 25 ms
24,288 KB
testcase_11 AC 25 ms
24,324 KB
testcase_12 AC 56 ms
24,264 KB
testcase_13 AC 60 ms
23,832 KB
testcase_14 AC 22 ms
24,312 KB
testcase_15 AC 23 ms
23,772 KB
testcase_16 AC 21 ms
23,976 KB
testcase_17 AC 22 ms
23,664 KB
testcase_18 AC 22 ms
24,216 KB
testcase_19 AC 22 ms
23,628 KB
testcase_20 AC 24 ms
23,628 KB
testcase_21 AC 102 ms
23,556 KB
testcase_22 AC 101 ms
24,264 KB
testcase_23 AC 54 ms
23,544 KB
testcase_24 AC 39 ms
24,312 KB
testcase_25 AC 64 ms
24,024 KB
testcase_26 AC 64 ms
23,388 KB
testcase_27 AC 40 ms
24,048 KB
testcase_28 AC 34 ms
23,652 KB
testcase_29 AC 107 ms
23,520 KB
testcase_30 AC 105 ms
23,772 KB
testcase_31 AC 22 ms
23,556 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `m`
  --> Main.rs:13:9
   |
13 |     let m = nm[1];
   |         ^ help: if this is intentional, prefix it with an underscore: `_m`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: 1 warning emitted

ソースコード

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; n]; 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 < n 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][n-1] == INF {
        println!("No");
    } else {
        println!("Yes");
    }
}
0