結果

問題 No.228 ゆきこちゃんの 15 パズル
ユーザー JunOnumaJunOnuma
提出日時 2017-05-22 16:47:15
言語 Python2
(2.7.18)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 716 bytes
コンパイル時間 408 ms
コンパイル使用メモリ 7,128 KB
実行使用メモリ 6,440 KB
最終ジャッジ日時 2023-10-19 14:07:42
合計ジャッジ時間 1,445 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

mp = [map(int, raw_input().split()) for _ in range(4)]
p = 0
q = 0
for y in range(4):
    for x in range(4):
        if mp[y][x] == 0:
            p = y
            q = x
while p != 3 or q != 3:
    n = p*4 + q + 1
    if p > 0 and mp[p-1][q] == n:
        mp[p][q] = n
        mp[p-1][q] = 0
        p = p-1
    elif p < 3 and mp[p+1][q] == n:
        mp[p][q] = n
        mp[p+1][q] = 0
        p = p+1
    elif q > 0 and mp[p][q-1] == n:
        mp[p][q] = n
        mp[p][q-1] = 0
        q = q-1
    elif q < 3 and mp[p][q+1] == n:
        mp[p][q] = n
        mp[p][q+1] = 0
        q = q+1
    else:
        break
if mp == [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,0]]:
    print 'Yes'
else:
    print 'No'
0