結果
| 問題 |
No.228 ゆきこちゃんの 15 パズル
|
| コンテスト | |
| ユーザー |
しらっ亭
|
| 提出日時 | 2015-07-09 00:28:52 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 949 bytes |
| コンパイル時間 | 88 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-07-08 01:45:16 |
| 合計ジャッジ時間 | 1,246 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 3 |
ソースコード
def check(B):
return all(B[i] == i for i in range(16))
def solve(B):
z = B.index(0)
B[z] = 16
B = [n - 1 for n in B]
while not check(B):
if z > 4:
if B[z - 4] == z:
B[z], B[z - 4] = B[z - 4], B[z]
z -= 4
continue
if z % 4 != 0:
if B[z - 1] == z:
B[z], B[z - 1] = B[z - 1], B[z]
z -= 1
continue
if z % 4 != 3:
if B[z + 1] == z:
B[z], B[z + 1] = B[z + 1], B[z]
z += 1
continue
if z < 12:
if B[z + 4] == z:
B[z], B[z + 4] = B[z + 4], B[z]
z += 4
continue
print('No')
return
print('Yes')
def main():
A = []
for i in range(4):
A.extend(list(map(int, input().split())))
solve(A)
if __name__ == '__main__':
main()
しらっ亭