結果

問題 No.228 ゆきこちゃんの 15 パズル
ユーザー kohei2019kohei2019
提出日時 2022-01-05 21:18:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 921 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 58,496 KB
最終ジャッジ日時 2024-04-24 01:54:48
合計ジャッジ時間 1,790 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
57,728 KB
testcase_01 AC 43 ms
57,856 KB
testcase_02 WA -
testcase_03 AC 42 ms
58,240 KB
testcase_04 AC 38 ms
58,496 KB
testcase_05 AC 37 ms
57,856 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 38 ms
58,240 KB
testcase_12 AC 41 ms
58,240 KB
testcase_13 AC 45 ms
58,368 KB
testcase_14 AC 45 ms
57,728 KB
testcase_15 AC 43 ms
58,112 KB
testcase_16 AC 44 ms
57,728 KB
testcase_17 AC 42 ms
57,856 KB
testcase_18 AC 44 ms
58,240 KB
testcase_19 AC 42 ms
57,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

ls = []
for i in range(4):
    ls += list(map(int,input().split()))
ls = tuple(ls)

kls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]
moveto = [-4,-1,1,4]
als = set()
def dfs(ls0):
    als.add(tuple(ls0))
    ind0 = ls0.index(0)
    if ind0 + 4 < 16:
        if ls0[ind0+4] == ind0+5:
            ls1 = ls0[:]
            ls1[ind0],ls1[ind0+4] = ls1[ind0+4],ls1[ind0]
            dfs(ls1)
    if ind0 - 4 >= 0:
        if ls0[ind0-4] == ind0-3:
            ls1 = ls0[:]
            ls1[ind0],ls1[ind0-4] = ls1[ind0-4],ls1[ind0]
            dfs(ls1)
    if ind0 % 4 != 0:
        if ls0[ind0-1] == ind0:
            ls1 = ls0[:]
            ls1[ind0],ls1[ind0-1] = ls1[ind0-1],ls1[ind0]
            dfs(ls1)
    if ind0 % 4 != 3:
        if ls0[ind0+1] == ind0:
            ls1 = ls0[:]
            ls1[ind0],ls1[ind0+1] = ls1[ind0+1],ls1[ind0]
            dfs(ls1)

dfs(kls)
print('Yes' if ls in als else 'No')
0