結果
| 問題 | No.228 ゆきこちゃんの 15 パズル |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-10 21:01:22 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 656 bytes |
| 記録 | |
| コンパイル時間 | 183 ms |
| コンパイル使用メモリ | 77,592 KB |
| 最終ジャッジ日時 | 2025-12-03 21:59:16 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 6 |
ソースコード
# -*- 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"