結果
問題 | No.228 ゆきこちゃんの 15 パズル |
ユーザー | kohei2019 |
提出日時 | 2022-01-05 21:21:20 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 55 ms / 5,000 ms |
コード長 | 923 bytes |
コンパイル時間 | 170 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 65,540 KB |
最終ジャッジ日時 | 2024-04-24 01:57:32 |
合計ジャッジ時間 | 1,924 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 55 ms
65,352 KB |
testcase_01 | AC | 55 ms
65,000 KB |
testcase_02 | AC | 52 ms
65,380 KB |
testcase_03 | AC | 49 ms
64,036 KB |
testcase_04 | AC | 49 ms
65,540 KB |
testcase_05 | AC | 51 ms
65,396 KB |
testcase_06 | AC | 50 ms
64,968 KB |
testcase_07 | AC | 50 ms
65,076 KB |
testcase_08 | AC | 50 ms
64,772 KB |
testcase_09 | AC | 52 ms
63,852 KB |
testcase_10 | AC | 52 ms
64,708 KB |
testcase_11 | AC | 52 ms
64,896 KB |
testcase_12 | AC | 51 ms
65,360 KB |
testcase_13 | AC | 49 ms
64,300 KB |
testcase_14 | AC | 50 ms
64,424 KB |
testcase_15 | AC | 47 ms
64,236 KB |
testcase_16 | AC | 50 ms
64,504 KB |
testcase_17 | AC | 52 ms
65,032 KB |
testcase_18 | AC | 49 ms
65,320 KB |
testcase_19 | AC | 47 ms
64,476 KB |
ソースコード
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+2: ls1 = ls0[:] ls1[ind0],ls1[ind0+1] = ls1[ind0+1],ls1[ind0] dfs(ls1) dfs(kls) print('Yes' if ls in als else 'No')