結果
問題 | No.228 ゆきこちゃんの 15 パズル |
ユーザー |
![]() |
提出日時 | 2024-06-08 00:08:27 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 52 ms / 5,000 ms |
コード長 | 733 bytes |
コンパイル時間 | 706 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 52,096 KB |
最終ジャッジ日時 | 2024-12-26 11:43:23 |
合計ジャッジ時間 | 2,924 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
A0 = [list(map(int,input().split())) for _ in range(4)]A = []N = [0] * 16q = []for i in range(16):h = i // 4w = i % 4A.append(A0[h][w] - 1)if A[i] == i:N[i] = 1if A[i] == -1:q.append(i)while q:x = q.pop()if x >= 4:if A[x - 4] == x:N[x] = 1q.append(x-4)continueif x < 12:if A[x + 4] == x:N[x] = 1q.append(x+4)continueif 0 < x % 4:if A[x - 1] == x:N[x] = 1q.append(x-1)continueif x % 4 < 3:if A[x+1] == x:N[x] = 1q.append(x+1)if sum(N) == 15:print("Yes")else:print("No")