結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2023-01-08 15:58:29 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 790 bytes |
コンパイル時間 | 11,679 ms |
コンパイル使用メモリ | 398,964 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-15 19:07:51 |
合計ジャッジ時間 | 13,038 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
fn solve(list: &mut Vec<(i32, i32)>, mov: &[(i32, i32)], p: i32, q: i32, x: i32, y: i32, n: i32) {if n <= 3 {list.push((p, q));for &m in mov {solve(list, &mov, p + m.0, q + m.1, x, y, n + 1)}}}fn main() {let mut s = String::new();std::io::stdin().read_line(&mut s).ok();let mut s = s.trim().split_whitespace();let x: i32 = s.next().unwrap().parse().unwrap();let y: i32 = s.next().unwrap().parse().unwrap();let m = vec![(-2, -1),(-2, 1),(-1, -2),(-1, 2),(1, -2),(1, 2),(2, -1),(2, 1),];let mut list = Vec::new();solve(&mut list, &m, 0, 0, x, y, 0);println!("{}", if list.contains(&(x, y)) { "YES" } else { "NO" });}