結果
| 問題 | No.228 ゆきこちゃんの 15 パズル |
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-02-02 21:54:55 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 97 ms / 5,000 ms |
| コード長 | 510 bytes |
| 記録 | |
| コンパイル時間 | 553 ms |
| コンパイル使用メモリ | 20,824 KB |
| 実行使用メモリ | 15,360 KB |
| 最終ジャッジ日時 | 2026-04-06 22:46:01 |
| 合計ジャッジ時間 | 3,630 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
*A, = map(int,read().split())
def dist(i,j):
xi,yi = divmod(i,4)
xj,yj = divmod(j,4)
return abs(xi-xj) + abs(yi-yj)
while True:
zero = A.index(0)
if zero == 15:
break
target = A.index(zero+1)
if dist(zero, target) > 1:
break
A[zero], A[target] = A[target], A[zero]
B = list(range(1,16)) + [0]
answer = 'Yes' if A == B else 'No'
print(answer)
maspy