結果

問題 No.228 ゆきこちゃんの 15 パズル
ユーザー maguroguma
提出日時 2017-09-03 16:55:26
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 565 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-11-06 20:04:54
合計ジャッジ時間 1,532 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

a = []
for i in range(4):
    a.append(list(map(int, input().split())))
A = [[1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,0]]

def find_n(n):
    for i in range(4):
        for j in range(4):
            if A[i][j] == n:
                return [i,j]

is_possible = True
for i in range(4):
    for j in range(4):
        n = a[i][j]
        coord = find_n(n)
        if abs(coord[0]-i)+abs(coord[1]-j) > 1:
            is_possible = False
            break
    if not is_possible:
        break

print('Yes') if is_possible else print('No')
0