結果
問題 | No.1588 Connection |
ユーザー |
![]() |
提出日時 | 2024-09-15 19:35:44 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 110 ms / 2,000 ms |
コード長 | 1,181 bytes |
コンパイル時間 | 13,193 ms |
コンパイル使用メモリ | 378,940 KB |
実行使用メモリ | 25,476 KB |
平均クエリ数 | 647.66 |
最終ジャッジ日時 | 2024-09-15 19:36:02 |
合計ジャッジ時間 | 16,881 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 31 |
コンパイルメッセージ
warning: unused variable: `m` --> src/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 --> src/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 --> src/main.rs:5:6 | 5 | type Deque<T> = VecDeque<T>; | ^^^^^
ソースコード
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();}