結果

問題 No.1588 Connection
ユーザー phsplsphspls
提出日時 2022-10-26 12:14:03
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,250 bytes
コンパイル時間 812 ms
コンパイル使用メモリ 149,668 KB
実行使用メモリ 24,444 KB
平均クエリ数 332.22
最終ジャッジ日時 2023-09-17 05:25:14
合計ジャッジ時間 4,499 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,964 KB
testcase_01 AC 24 ms
23,952 KB
testcase_02 AC 24 ms
24,024 KB
testcase_03 AC 24 ms
23,436 KB
testcase_04 AC 24 ms
24,024 KB
testcase_05 AC 24 ms
24,336 KB
testcase_06 AC 25 ms
23,772 KB
testcase_07 AC 25 ms
24,012 KB
testcase_08 AC 25 ms
23,664 KB
testcase_09 AC 27 ms
24,216 KB
testcase_10 AC 28 ms
23,772 KB
testcase_11 AC 27 ms
24,024 KB
testcase_12 AC 53 ms
23,532 KB
testcase_13 AC 53 ms
23,484 KB
testcase_14 AC 25 ms
24,000 KB
testcase_15 AC 26 ms
23,376 KB
testcase_16 AC 25 ms
23,556 KB
testcase_17 AC 25 ms
23,388 KB
testcase_18 AC 25 ms
23,580 KB
testcase_19 AC 25 ms
23,964 KB
testcase_20 AC 28 ms
24,336 KB
testcase_21 AC 87 ms
23,352 KB
testcase_22 AC 88 ms
23,592 KB
testcase_23 AC 50 ms
23,388 KB
testcase_24 AC 38 ms
23,460 KB
testcase_25 AC 59 ms
23,952 KB
testcase_26 AC 58 ms
23,988 KB
testcase_27 AC 38 ms
23,844 KB
testcase_28 AC 35 ms
23,556 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 24 ms
23,352 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `VecDeque`
 --> Main.rs:1:24
  |
1 | use std::collections::{VecDeque, BinaryHeap};
  |                        ^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: 1 warning emitted

ソースコード

diff #

use std::collections::{VecDeque, BinaryHeap};


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 pque = BinaryHeap::new();
    pque.push((1, 0, 1));
    pque.push((1, 1, 0));
    while let Some((_, x, y)) = pque.pop() {
        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 {
                pque.push((x+1+y, x+1, y));
            }
            if y+1 < n && grid[x][y+1] == 2 {
                pque.push((x+y+1, x, y+1));
            }
        }
        cnt += 1;
        if cnt == 3000 { break; }
    }
    println!("{}", if grid[n-2][n-1] == 1 || grid[n-1][n-2] == 1 { "Yes" } else { "No" });
}
0