結果

問題 No.228 ゆきこちゃんの 15 パズル
ユーザー titiatitia
提出日時 2022-07-19 03:28:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 487 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 10,996 KB
実行使用メモリ 8,312 KB
最終ジャッジ日時 2023-09-13 19:39:13
合計ジャッジ時間 1,498 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,236 KB
testcase_01 AC 15 ms
7,956 KB
testcase_02 AC 16 ms
7,968 KB
testcase_03 AC 16 ms
8,172 KB
testcase_04 AC 16 ms
7,932 KB
testcase_05 AC 16 ms
7,824 KB
testcase_06 AC 17 ms
7,784 KB
testcase_07 AC 16 ms
7,824 KB
testcase_08 AC 15 ms
7,784 KB
testcase_09 AC 15 ms
7,784 KB
testcase_10 AC 16 ms
7,960 KB
testcase_11 AC 15 ms
8,004 KB
testcase_12 AC 15 ms
8,268 KB
testcase_13 AC 15 ms
8,116 KB
testcase_14 AC 15 ms
8,312 KB
testcase_15 AC 15 ms
8,260 KB
testcase_16 AC 15 ms
8,116 KB
testcase_17 AC 15 ms
8,120 KB
testcase_18 AC 16 ms
8,296 KB
testcase_19 AC 15 ms
8,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

while NOW!=A:
    for i in range(4):
        for j in range(4):
            if NOW[i][j]==0:
                x=i
                y=j

    k=A[x][y]

    for z,w in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]:
        if 0<=z<4 and 0<=w<4 and NOW[z][w]==k:
            NOW[z][w],NOW[x][y]=NOW[x][y],NOW[z][w]
            break
    else:
        print("No")
        exit()

print("Yes")

    
0