結果

問題 No.240 ナイト散歩
ユーザー mban
提出日時 2016-12-23 14:48:13
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,372 bytes
コンパイル時間 1,158 ms
コンパイル使用メモリ 112,716 KB
実行使用メモリ 28,472 KB
最終ジャッジ日時 2024-10-07 21:33:36
合計ジャッジ時間 3,269 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro
{
    static int[] IdouX = new int[8] { -2, -2, -1, -1, 1, 1, 2, 2 };
    static int[] IdouY = new int[8] { -1, 1, -2, 2, -2, 2, -1, 1 };
    static void Main()
    {
        XY P;
        string[] s = Console.ReadLine().Split(' ');
        P.X = long.Parse(s[0]);
        P.Y = long.Parse(s[1]);
        HashSet<XY>[] Hs = new HashSet<XY>[4];
        for(int i = 0; i < 4; i++)
        {
            Hs[i] = new HashSet<XY>();
        }
        Hs[0].Add(new XY(0, 0));
        for(int i = 1; i <= 3; i++)
        {
            foreach(XY v in Hs[i-1].ToArray())
            {
             
                for(int j = 0; j < 8; j++)
                {
                    XY q = v;
                    q.X += IdouX[j];
                    q.Y += IdouY[j];
                    Hs[i].Add(q);
                }
            }
        }
        for (int i = 0; i < 4; i++)
        {
            if (Hs[i].Contains(P))
            {
                Console.WriteLine("YES");
                return;
            }
        }
        Console.WriteLine("NO");


    }

}
struct XY
{
    public long X, Y;
    public XY(long x,long y)
    {
        X = x;
        Y = y;
    }
}
0