結果

問題 No.240 ナイト散歩
コンテスト
ユーザー mk
提出日時 2022-01-11 10:31:45
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,490 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,792 ms
コンパイル使用メモリ 189,260 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-09 23:33:34
合計ジャッジ時間 4,721 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#[macro_export]
macro_rules! setup {
    { mut $input:ident: SplitWhitespace $(,)? } => {
        use std::io::Read;
        let mut buf = String::new();
        std::io::stdin().read_to_string(&mut buf).unwrap();
        let mut $input = buf.split_whitespace();
    };
}

#[macro_export]
macro_rules! parse_next {
    ($str_iter:expr) => {
        $str_iter.next().unwrap().parse().unwrap()
    };
}

fn main() {
    setup! { mut input: SplitWhitespace };

    let x: i64 = parse_next!(input);
    let y: i64 = parse_next!(input);

    macro_rules! walk {
        ($x:expr, $y:expr, $store:expr) => {{
            $store.push(($x - 2, $y - 1));
            $store.push(($x - 2, $y + 1));
            $store.push(($x - 1, $y - 2));
            $store.push(($x - 1, $y + 2));
            $store.push(($x + 1, $y - 2));
            $store.push(($x + 1, $y + 2));
            $store.push(($x + 2, $y - 1));
            $store.push(($x + 2, $y + 1));
        }};
    }

    let mut store = vec![];
    {
        store.push((0, 0));
    }
    for i in 0..store.len() {
        walk!(store[i].0, store[i].1, store);
    }
    for i in 1..store.len() {
        walk!(store[i].0, store[i].1, store);
    }
    for i in (1 + 8)..store.len() {
        walk!(store[i].0, store[i].1, store);
    }

    store.sort();
    store.dedup();

    let ans = match store.into_iter().find(|(x_i, y_i)| (*x_i, *y_i) == (x, y)) {
        Some(_) => "YES",
        None => "NO",
    };

    println!("{}", ans);
}
0