結果

問題 No.228 ゆきこちゃんの 15 パズル
ユーザー mobius_bkstmobius_bkst
提出日時 2015-06-19 22:52:42
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,728 bytes
コンパイル時間 4,060 ms
コンパイル使用メモリ 77,372 KB
実行使用メモリ 49,608 KB
最終ジャッジ日時 2023-09-21 10:03:05
合計ジャッジ時間 5,327 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 39 ms
49,200 KB
testcase_02 AC 38 ms
49,412 KB
testcase_03 AC 39 ms
49,568 KB
testcase_04 AC 38 ms
49,292 KB
testcase_05 AC 39 ms
49,412 KB
testcase_06 AC 40 ms
49,492 KB
testcase_07 AC 37 ms
47,900 KB
testcase_08 AC 39 ms
49,608 KB
testcase_09 AC 37 ms
49,368 KB
testcase_10 AC 38 ms
49,476 KB
testcase_11 AC 38 ms
49,252 KB
testcase_12 WA -
testcase_13 AC 40 ms
49,296 KB
testcase_14 AC 39 ms
49,356 KB
testcase_15 AC 39 ms
49,240 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 38 ms
49,444 KB
testcase_19 AC 37 ms
49,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No278 {
    public static void main(String[] args) {
        try {
            int goal[][] = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 },
                    { 13, 14, 15, 0 } };
            BufferedReader br = new BufferedReader(new InputStreamReader(
                    System.in));
            int start[][] = new int[4][4];
            for (int i = 0; i < 4; i++) {
                start[i] = strToIntArray(br.readLine());
            }
            String str = "Yes";
            for (int i = 0; i < 4; i++) {
                for (int j = 0; j < 4; j++) {
                    if (goal[i][j] == 0) {
                        continue;
                    }
                    for (int j2 = 0; j2 < 4; j2++) {
                        for (int k = 0; k < 4; k++) {
                            // 距離が2以上離れてたらむりだろ
                            if (goal[i][j] == start[j2][k]) {
                                if (1 < Math.abs(i - j2) + Math.abs(j - k)) {
                                    str = "No";
                                }
                            }
                        }
                    }
                }
            }
            System.out.println(str);
        } catch (Exception e) {
            e.printStackTrace();
            System.err.println("Error:" + e.getMessage());
        }
    }

    static int[] strToIntArray(String S) {
        String[] strArray = S.split(" ");
        int[] intArray = new int[strArray.length];
        for (int i = 0; i < strArray.length; i++) {
            intArray[i] = Integer.parseInt(strArray[i]);
        }
        return intArray;
    }
}
0