結果
問題 | No.228 ゆきこちゃんの 15 パズル |
ユーザー |
![]() |
提出日時 | 2017-05-25 15:16:10 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 29 ms / 5,000 ms |
コード長 | 1,016 bytes |
コンパイル時間 | 145 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-09-19 19:13:31 |
合計ジャッジ時間 | 1,345 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
l = [0] * 4 for i in range(4): l[i] = list(map(int, input().split())) moved = [False] * 15 y = 0 while(y < 4): x = 0 while(x < 4): if l[y][x] == 0: a = 1 + x + y * 4 for p, q in [[y-1, x], [y+1, x], [y, x-1], [y, x+1]]: try: if l[p][q] == a: if not moved[a-1]: l[p][q], l[y][x] = l[y][x], l[p][q] moved[a-1] = True x = -1 y = 0 break else: x = float("inf") y = float("inf") break except IndexError: pass else: x = float("inf") y = float("inf") x += 1 y += 1 if l == [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 0]]: print("Yes") else: print("No")