結果

問題 No.228 ゆきこちゃんの 15 パズル
ユーザー 12354865271235486527
提出日時 2019-12-14 11:34:49
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 622 bytes
コンパイル時間 885 ms
コンパイル使用メモリ 10,756 KB
実行使用メモリ 7,936 KB
最終ジャッジ日時 2023-09-10 11:49:10
合計ジャッジ時間 2,182 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,736 KB
testcase_01 AC 16 ms
7,844 KB
testcase_02 AC 16 ms
7,748 KB
testcase_03 AC 16 ms
7,884 KB
testcase_04 AC 17 ms
7,876 KB
testcase_05 AC 16 ms
7,844 KB
testcase_06 AC 16 ms
7,804 KB
testcase_07 AC 16 ms
7,820 KB
testcase_08 AC 16 ms
7,824 KB
testcase_09 AC 17 ms
7,820 KB
testcase_10 AC 16 ms
7,924 KB
testcase_11 AC 16 ms
7,876 KB
testcase_12 AC 16 ms
7,920 KB
testcase_13 AC 16 ms
7,876 KB
testcase_14 AC 16 ms
7,840 KB
testcase_15 AC 16 ms
7,796 KB
testcase_16 AC 16 ms
7,756 KB
testcase_17 AC 16 ms
7,828 KB
testcase_18 AC 16 ms
7,936 KB
testcase_19 AC 15 ms
7,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

a = [list(map(int, input().split())) for _ in range(4)]
c = [[(i+j)%16 for i in range(1, 5)] for j in range(0,16,4)]
dy = [-1, 0, 1, 0]
dx = [0, -1, 0, 1]
loop = True
while loop:
    for y in range(4):
        for x in range(4):
            if a[y][x] == 0:
                for k in range(4):
                    ty = dy[k] + y
                    tx = dx[k] + x
                    if 0 <= ty < 4 and  0 <= tx < 4 and a[ty][tx] == c[y][x]:
                        a[y][x], a[ty][tx] = a[ty][tx], a[y][x]
                        break
                else:
                    loop = False
print('Yes' if a == c else 'No')
0