結果

問題 No.240 ナイト散歩
ユーザー bluemeganebluemegane
提出日時 2018-09-29 16:39:02
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,107 bytes
コンパイル時間 1,118 ms
コンパイル使用メモリ 112,692 KB
実行使用メモリ 27,140 KB
最終ジャッジ日時 2024-04-20 12:53:24
合計ジャッジ時間 3,113 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,844 KB
testcase_01 AC 28 ms
25,100 KB
testcase_02 AC 29 ms
27,140 KB
testcase_03 AC 29 ms
26,884 KB
testcase_04 AC 28 ms
24,984 KB
testcase_05 AC 28 ms
22,704 KB
testcase_06 AC 29 ms
27,024 KB
testcase_07 AC 27 ms
27,092 KB
testcase_08 AC 29 ms
26,640 KB
testcase_09 AC 29 ms
26,764 KB
testcase_10 AC 28 ms
24,720 KB
testcase_11 AC 28 ms
24,848 KB
testcase_12 AC 31 ms
25,100 KB
testcase_13 AC 28 ms
24,924 KB
testcase_14 AC 28 ms
24,800 KB
testcase_15 AC 27 ms
24,920 KB
testcase_16 AC 28 ms
26,712 KB
testcase_17 AC 27 ms
24,628 KB
testcase_18 AC 29 ms
22,588 KB
testcase_19 AC 28 ms
26,888 KB
testcase_20 AC 28 ms
26,840 KB
testcase_21 AC 28 ms
24,928 KB
testcase_22 AC 29 ms
22,968 KB
testcase_23 AC 28 ms
22,840 KB
testcase_24 AC 29 ms
24,536 KB
testcase_25 AC 28 ms
26,896 KB
testcase_26 AC 27 ms
24,796 KB
testcase_27 AC 27 ms
26,964 KB
testcase_28 AC 28 ms
25,052 KB
testcase_29 AC 28 ms
26,764 KB
testcase_30 AC 29 ms
26,888 KB
testcase_31 AC 29 ms
27,020 KB
testcase_32 AC 27 ms
24,972 KB
testcase_33 AC 27 ms
24,844 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Collections.Generic;
using System.Linq;
using System;

public class P
{
    public int x { get; set; }
    public int y { get; set; }
    public int times { get; set; }
}

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var x = int.Parse(line[0]);
        var y = int.Parse(line[1]);
        Console.WriteLine(getAns(x,y) ? "YES":"NO");
    }
    public static bool getAns ( int x , int y)
    {
        if (x == 0 && y == 0) return true;
        var dx = new int[] { 1, 2, 2, 1, -1, -2, -2, -1 };
        var dy = new int[] { 2, 1, -1, -2, -2, -1, 1, 2 };
        var q = new Queue<P>();
        for (int i = 0; i < 8; i++) q.Enqueue(new P { x = dx[i], y = dy[i] ,times = 1});
        while (q.Count() > 0)
        {
            var w = q.Dequeue();
            if (w.x == x && w.y == y) return true;
            if (w.times == 3) continue;
            for (int i = 0; i < 8; i++)
                q.Enqueue(new P { x = w.x + dx[i], y = w.y +  dy[i], times = w.times + 1 });
        }
        return false;
    }
}
0