結果

問題 No.1588 Connection
ユーザー phsplsphspls
提出日時 2022-11-10 11:16:59
言語 Rust
(1.77.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 1,350 bytes
コンパイル時間 1,037 ms
コンパイル使用メモリ 147,644 KB
実行使用メモリ 24,384 KB
平均クエリ数 552.72
最終ジャッジ日時 2023-09-30 20:15:00
合計ジャッジ時間 4,737 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
23,760 KB
testcase_01 AC 25 ms
23,604 KB
testcase_02 AC 24 ms
23,568 KB
testcase_03 AC 24 ms
23,352 KB
testcase_04 AC 25 ms
23,484 KB
testcase_05 AC 25 ms
24,384 KB
testcase_06 AC 24 ms
24,384 KB
testcase_07 AC 24 ms
24,012 KB
testcase_08 AC 27 ms
24,012 KB
testcase_09 AC 27 ms
24,012 KB
testcase_10 AC 29 ms
23,964 KB
testcase_11 AC 28 ms
23,592 KB
testcase_12 AC 55 ms
23,988 KB
testcase_13 AC 61 ms
23,364 KB
testcase_14 AC 24 ms
23,388 KB
testcase_15 AC 25 ms
24,252 KB
testcase_16 AC 24 ms
23,796 KB
testcase_17 AC 25 ms
23,400 KB
testcase_18 AC 24 ms
23,592 KB
testcase_19 AC 25 ms
24,336 KB
testcase_20 AC 28 ms
23,376 KB
testcase_21 AC 101 ms
23,580 KB
testcase_22 AC 101 ms
23,964 KB
testcase_23 AC 55 ms
23,352 KB
testcase_24 AC 42 ms
23,388 KB
testcase_25 AC 66 ms
24,384 KB
testcase_26 AC 65 ms
24,024 KB
testcase_27 AC 42 ms
23,556 KB
testcase_28 AC 37 ms
24,264 KB
testcase_29 AC 99 ms
23,604 KB
testcase_30 AC 98 ms
23,772 KB
testcase_31 AC 24 ms
23,784 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((0, 0));
    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 == "White" {
            grid[x][y] = 0;
            continue;
        }
        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));
            }
        }
        if grid[n-1][n-1] < INF { break; }
    }
    if grid[n-1][n-1] < INF {
        println!("Yes");
    } else {
        println!("No");
    }
}
0