結果

問題 No.240 ナイト散歩
ユーザー mastersatoshi
提出日時 2015-07-16 16:05:14
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,900 bytes
コンパイル時間 1,860 ms
コンパイル使用メモリ 76,196 KB
実行使用メモリ 37,172 KB
最終ジャッジ日時 2024-07-08 08:12:46
合計ジャッジ時間 4,181 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 25 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    //取りうる座標を全て定数化しておく
    private static final int dest[][] = new int[][]{{-6, -3},
    {-6, -1},
    {-6, 1},
    {-6, 3},
    {-5, -4},
    {-5, -2},
    {-5, 0},
    {-5, 2},
    {-5, 4},
    {-4, -5},
    {-4, -3},
    {-4, -1},
    {-4, 1},
    {-4, 3},
    {-4, 5},
    {-3, -6},
    {-3, -4},
    {-3, -2},
    {-3, 0},
    {-3, 2},
    {-3, 4},
    {-3, 6},
    {-2, -5},
    {-2, -3},
    {-2, -1},
    {-2, 1},
    {-2, 3},
    {-2, 5},
    {-1, -6},
    {-1, -4},
    {-1, -2},
    {-1, 0},
    {-1, 2},
    {-1, 4},
    {-1, 6},
    {0, -5},
    {0, -3},
    {0, -1},
    {0, 0},
    {0, 1},
    {0, 3},
    {0, 5},
    {1, -6},
    {1, -4},
    {1, -2},
    {1, 0},
    {1, 2},
    {1, 4},
    {1, 6},
    {2, -5},
    {2, -3},
    {2, -1},
    {2, 1},
    {2, 3},
    {2, 5},
    {3, -6},
    {3, -4},
    {3, -2},
    {3, 0},
    {3, 2},
    {3, 4},
    {3, 6},
    {4, -5},
    {4, -3},
    {4, -1},
    {4, 1},
    {4, 3},
    {4, 5},
    {5, -4},
    {5, -2},
    {5, 0},
    {5, 2},
    {5, 4},
    {6, -3},
    {6, -1},
    {6, 1},
    {6, 3}};

    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String str;

        while (!"".equals(str = br.readLine())) {

            if (str == null) {
                break;
            }

            String strs[] = str.split(" ");

            int place[] = new int[]{Integer.parseInt(strs[0]), Integer.parseInt(strs[1])};

            for (int i = 0; i < dest.length; i++) {
                if (dest[i][0] == place[0] && dest[i][1] == place[1]) {
                    System.out.println("YES");
                    return;
                }
            }

            System.out.println("NO");

        }
    }
}
0