結果

問題 No.1588 Connection
ユーザー phsplsphspls
提出日時 2022-10-27 12:12:23
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,222 bytes
コンパイル時間 2,411 ms
コンパイル使用メモリ 147,016 KB
実行使用メモリ 24,324 KB
平均クエリ数 332.22
最終ジャッジ日時 2023-09-18 05:55:41
合計ジャッジ時間 4,754 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,616 KB
testcase_01 AC 26 ms
23,532 KB
testcase_02 AC 25 ms
23,976 KB
testcase_03 AC 25 ms
23,352 KB
testcase_04 AC 26 ms
23,880 KB
testcase_05 AC 24 ms
24,108 KB
testcase_06 AC 26 ms
24,288 KB
testcase_07 AC 25 ms
23,448 KB
testcase_08 AC 26 ms
23,652 KB
testcase_09 AC 27 ms
23,556 KB
testcase_10 AC 28 ms
23,604 KB
testcase_11 AC 28 ms
24,228 KB
testcase_12 AC 54 ms
24,108 KB
testcase_13 AC 55 ms
24,324 KB
testcase_14 AC 25 ms
23,652 KB
testcase_15 AC 26 ms
23,892 KB
testcase_16 AC 25 ms
23,328 KB
testcase_17 AC 26 ms
23,544 KB
testcase_18 AC 26 ms
23,556 KB
testcase_19 AC 26 ms
23,544 KB
testcase_20 AC 29 ms
24,036 KB
testcase_21 AC 87 ms
23,328 KB
testcase_22 AC 89 ms
23,412 KB
testcase_23 AC 49 ms
23,808 KB
testcase_24 AC 38 ms
24,024 KB
testcase_25 AC 59 ms
23,556 KB
testcase_26 AC 60 ms
24,036 KB
testcase_27 AC 39 ms
23,736 KB
testcase_28 AC 36 ms
23,520 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 25 ms
23,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::VecDeque;


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];
    if 2*n-1 > m {
        println!("No");
        return;
    }

    let mut grid = vec![vec![2usize; n]; n];
    grid[0][0] = 1;
    let mut cnt = 0usize;
    let mut deque = VecDeque::new();
    deque.push_back((0, 1));
    deque.push_back((1, 0));
    while let Some((x, y)) = deque.pop_front() {
        if grid[x][y] < 2 {
            continue;
        }
        println!("{} {}", x+1, y+1);
        let mut temp = String::new();
        std::io::stdin().read_line(&mut temp).ok();
        let temp = temp.trim();
        if temp == "White" {
            grid[x][y] = 0;
        } else {
            grid[x][y] = 1;
            if x+1 < n && grid[x+1][y] == 2 {
                deque.push_front((x+1, y));
            }
            if y+1 < n && grid[x][y+1] == 2 {
                deque.push_front((x, y+1));
            }
        }
        cnt += 1;
        if cnt == 3000 { break; }
    }
    println!("{}", if grid[n-1][n-1] == 1 { "Yes" } else { "No" });
}
0