結果
| 問題 | No.3598 Queen vs. King |
| コンテスト | |
| ユーザー |
urectanc
|
| 提出日時 | 2026-07-24 21:58:52 |
| 言語 | Rust (1.94.0 + proconio + num + itertools) |
| 結果 |
AC
|
| 実行時間 | 49 ms / 2,000 ms |
| + 0µs | |
| コード長 | 1,636 bytes |
| 記録 | |
| コンパイル時間 | 1,268 ms |
| コンパイル使用メモリ | 185,112 KB |
| 実行使用メモリ | 6,016 KB |
| 平均クエリ数 | 1702.83 |
| 最終ジャッジ日時 | 2026-07-24 22:00:02 |
| 合計ジャッジ時間 | 2,997 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 10 |
ソースコード
use proconio::input;
fn main() {
input! { t: usize }
for _ in 0..t {
solve();
}
}
fn solve() {
input! { h: i32, w: i32 }
let mut current = (1, 1);
for _ in 0..3 {
input! { x: i32, y: i32 }
assert_ne!((x, y), (-1, -1));
if (x, y) == (0, 0) {
return;
}
let cand = if x == h {
[
(x - 1, y),
(x - 1, current.1),
(x - 1, current.1 + 1),
(x - 1, current.1 - 1),
]
} else if y == w {
[
(x, y - 1),
(current.0, y - 1),
(current.0 + 1, y - 1),
(current.0 - 1, y - 1),
]
} else {
[
(x - 1, y),
(x - 1, current.1),
(x - 1, current.1 + 1),
(x - 1, current.1 - 1),
]
};
let (ni, nj) = cand
.iter()
.copied()
.find(|&next| {
(1..=h).contains(&next.0)
&& (1..=w).contains(&next.1)
&& current != next
&& check(current, next)
})
.unwrap();
println!("{ni} {nj}");
current = (ni, nj);
}
input! { x: i32, y: i32 }
assert_ne!((x, y), (-1, -1));
if (x, y) == (0, 0) {
return;
}
unreachable!()
}
fn check(now: (i32, i32), prev: (i32, i32)) -> bool {
now.0 == prev.0
|| now.1 == prev.1
|| now.0 + now.1 == prev.0 + prev.1
|| now.0 + prev.1 == prev.0 + now.1
}
urectanc