結果

問題 No.1588 Connection
ユーザー akakimidoriakakimidori
提出日時 2021-07-08 22:36:21
言語 Rust
(1.77.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 1,181 bytes
コンパイル時間 1,796 ms
コンパイル使用メモリ 165,592 KB
実行使用メモリ 24,504 KB
平均クエリ数 647.66
最終ジャッジ日時 2023-09-24 10:46:02
合計ジャッジ時間 5,100 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,556 KB
testcase_01 AC 25 ms
24,072 KB
testcase_02 AC 24 ms
23,424 KB
testcase_03 AC 24 ms
24,036 KB
testcase_04 AC 23 ms
23,376 KB
testcase_05 AC 25 ms
23,664 KB
testcase_06 AC 25 ms
24,060 KB
testcase_07 AC 24 ms
24,216 KB
testcase_08 AC 28 ms
24,372 KB
testcase_09 AC 28 ms
24,504 KB
testcase_10 AC 27 ms
24,432 KB
testcase_11 AC 26 ms
23,844 KB
testcase_12 AC 55 ms
24,216 KB
testcase_13 AC 73 ms
23,652 KB
testcase_14 AC 24 ms
23,652 KB
testcase_15 AC 25 ms
23,640 KB
testcase_16 AC 24 ms
24,060 KB
testcase_17 AC 25 ms
23,640 KB
testcase_18 AC 25 ms
23,664 KB
testcase_19 AC 25 ms
23,436 KB
testcase_20 AC 24 ms
24,036 KB
testcase_21 AC 114 ms
24,408 KB
testcase_22 AC 111 ms
23,424 KB
testcase_23 AC 60 ms
23,688 KB
testcase_24 AC 44 ms
23,436 KB
testcase_25 AC 70 ms
23,400 KB
testcase_26 AC 69 ms
23,808 KB
testcase_27 AC 42 ms
23,412 KB
testcase_28 AC 39 ms
23,832 KB
testcase_29 AC 103 ms
24,408 KB
testcase_30 AC 106 ms
23,856 KB
testcase_31 AC 24 ms
23,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `m`
  --> Main.rs:14:13
   |
14 |     let (n, m): (usize, usize) = {
   |             ^ help: if this is intentional, prefix it with an underscore: `_m`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: type alias `Map` is never used
 --> Main.rs:3:6
  |
3 | type Map<K, V> = BTreeMap<K, V>;
  |      ^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: type alias `Deque` is never used
 --> Main.rs:5:6
  |
5 | type Deque<T> = VecDeque<T>;
  |      ^^^^^

warning: 3 warnings emitted

ソースコード

diff #

use std::collections::*;

type Map<K, V> = BTreeMap<K, V>;
type Set<T> = BTreeSet<T>;
type Deque<T> = VecDeque<T>;

fn read() -> Vec<String> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|s| String::from(s)).collect()
}

fn run() {
    let (n, m): (usize, usize) = {
        let a = read();
        (a[0].parse().unwrap(), a[1].parse().unwrap())
    };
    let mut set = Set::new();
    set.insert((0, 0));
    let mut dfs = vec![(0, 0)];
    while let Some((x, y)) = dfs.pop() {
        for &(x, y) in [(x - 1, y), (x + 1, y), (x, y - 1), (x, y + 1)].iter() {
            if x < n && y < n && !set.contains(&(x, y)) {
                println!("{} {}", x + 1, y + 1);
                let res = read();
                if res[0] == "Black" {
                    set.insert((x, y));
                    dfs.push((x, y));
                } else if res[0] == "White" {
                } else {
                    unreachable!();
                }
            }
        }
    }
    if set.contains(&(n - 1, n - 1)) {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    run();
}
0