結果

問題 No.228 ゆきこちゃんの 15 パズル
ユーザー magurogumamaguroguma
提出日時 2017-09-03 16:55:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 565 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-24 12:14:57
合計ジャッジ時間 1,250 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 27 ms
10,496 KB
testcase_02 AC 27 ms
10,752 KB
testcase_03 AC 28 ms
10,752 KB
testcase_04 AC 25 ms
10,624 KB
testcase_05 AC 25 ms
10,624 KB
testcase_06 AC 25 ms
10,752 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 26 ms
10,752 KB
testcase_14 AC 26 ms
10,624 KB
testcase_15 AC 26 ms
10,752 KB
testcase_16 WA -
testcase_17 AC 27 ms
10,624 KB
testcase_18 AC 26 ms
10,752 KB
testcase_19 AC 26 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

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