結果
問題 |
No.228 ゆきこちゃんの 15 パズル
|
ユーザー |
![]() |
提出日時 | 2020-02-02 21:54:55 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 32 ms / 5,000 ms |
コード長 | 510 bytes |
コンパイル時間 | 149 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-09-18 21:27:50 |
合計ジャッジ時間 | 1,607 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)