結果

問題 No.1588 Connection
ユーザー phsplsphspls
提出日時 2022-10-26 12:04:47
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,220 bytes
コンパイル時間 2,644 ms
コンパイル使用メモリ 149,292 KB
実行使用メモリ 24,348 KB
平均クエリ数 332.22
最終ジャッジ日時 2023-09-17 05:19:07
合計ジャッジ時間 6,858 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,568 KB
testcase_01 AC 24 ms
23,316 KB
testcase_02 AC 25 ms
23,988 KB
testcase_03 AC 25 ms
23,352 KB
testcase_04 AC 25 ms
23,976 KB
testcase_05 AC 25 ms
24,264 KB
testcase_06 AC 25 ms
23,568 KB
testcase_07 AC 24 ms
23,592 KB
testcase_08 AC 26 ms
23,340 KB
testcase_09 AC 27 ms
23,472 KB
testcase_10 AC 28 ms
23,568 KB
testcase_11 AC 28 ms
23,616 KB
testcase_12 AC 55 ms
23,364 KB
testcase_13 AC 55 ms
23,364 KB
testcase_14 AC 25 ms
24,288 KB
testcase_15 AC 26 ms
23,964 KB
testcase_16 AC 25 ms
24,276 KB
testcase_17 AC 25 ms
23,484 KB
testcase_18 AC 24 ms
24,252 KB
testcase_19 AC 26 ms
24,000 KB
testcase_20 AC 28 ms
23,472 KB
testcase_21 AC 88 ms
23,568 KB
testcase_22 AC 89 ms
23,580 KB
testcase_23 AC 51 ms
23,604 KB
testcase_24 AC 38 ms
24,324 KB
testcase_25 AC 59 ms
23,952 KB
testcase_26 AC 57 ms
23,604 KB
testcase_27 AC 38 ms
23,976 KB
testcase_28 AC 34 ms
23,316 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 24 ms
24,348 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_back((x+1, y));
            }
            if y+1 < n && grid[x][y+1] == 2 {
                deque.push_back((x, y+1));
            }
        }
        cnt += 1;
        if cnt == 3000 { break; }
    }
    println!("{}", if grid[n-1][n-1] == 1 { "Yes" } else { "No" });
}
0