結果

問題 No.228 ゆきこちゃんの 15 パズル
ユーザー roiti46roiti46
提出日時 2016-10-10 21:01:22
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 656 bytes
コンパイル時間 48 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2024-05-01 19:03:03
合計ジャッジ時間 1,187 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

r = {i + 1:(i%4, i/4) for i in xrange(15)}
a = [map(int, raw_input().split()) for i in xrange(4)]

for y in xrange(4):
    for x in xrange(4):
        if a[y][x] == 0: continue
        xx, yy = r[a[y][x]]
        if abs(xx - x) + abs(yy - y) > 1:
            print "No"
            exit()
t = 0
for i in xrange(16):
    if a[i/4][i%4] == 0:
        t += abs(3 - i%4) + abs(3 - i/4)
        continue
    for j in xrange(i + 1, 16):
        if a[j/4][j%4] == 0: continue
        if a[i/4][i%4] > a[j/4][j%4]: t += 1
print "Yes" if t%2 == 0 else "No"
0