結果
| 問題 |
No.1588 Connection
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-26 12:14:03 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,250 bytes |
| コンパイル時間 | 14,382 ms |
| コンパイル使用メモリ | 399,316 KB |
| 実行使用メモリ | 25,716 KB |
| 平均クエリ数 | 332.22 |
| 最終ジャッジ日時 | 2024-07-04 02:46:19 |
| 合計ジャッジ時間 | 15,684 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 29 WA * 2 |
コンパイルメッセージ
warning: unused import: `VecDeque`
--> src/main.rs:1:24
|
1 | use std::collections::{VecDeque, BinaryHeap};
| ^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
ソースコード
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" });
}