結果
問題 | No.240 ナイト散歩 |
ユーザー |
|
提出日時 | 2020-04-29 01:38:27 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 893 bytes |
コンパイル時間 | 12,208 ms |
コンパイル使用メモリ | 378,004 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-26 09:05:19 |
合計ジャッジ時間 | 13,085 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
use std::io::*;fn dfs(list: &mut Vec<(i64, i64)>, mov: &[(i64, i64)], d: usize, cx: i64, cy: i64) {if d <= 3 {list.push((cx, cy));for &m in mov.iter() {dfs(list, &mov, d + 1, cx + m.0, cy + m.1);}}}fn main() {let mut s: String = String::new();std::io::stdin().read_to_string(&mut s).ok();let mut itr = s.trim().split_whitespace();let p = (itr.next().unwrap().parse::<i64>().unwrap(),itr.next().unwrap().parse::<i64>().unwrap(),);let mov = [(-2, -1),(-2, 1),(-1, -2),(-1, 2),(1, -2),(1, 2),(2, -1),(2, 1),].to_vec();let mut list = Vec::new();dfs(&mut list, &mov, 0, 0, 0);if let Some(_) = list.iter().find(|&&x| x == p) {println!("YES",)} else {println!("NO",)}}