結果

問題 No.228 ゆきこちゃんの 15 パズル
ユーザー cielciel
提出日時 2015-11-01 03:54:36
言語 Ruby
(3.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 372 bytes
コンパイル時間 56 ms
コンパイル使用メモリ 11,500 KB
実行使用メモリ 15,352 KB
最終ジャッジ日時 2023-10-11 07:41:57
合計ジャッジ時間 2,752 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 83 ms
15,132 KB
testcase_02 AC 84 ms
15,304 KB
testcase_03 AC 83 ms
15,344 KB
testcase_04 AC 84 ms
15,248 KB
testcase_05 AC 84 ms
15,136 KB
testcase_06 AC 84 ms
15,304 KB
testcase_07 AC 83 ms
15,304 KB
testcase_08 AC 84 ms
15,196 KB
testcase_09 AC 83 ms
15,036 KB
testcase_10 AC 83 ms
15,352 KB
testcase_11 AC 83 ms
15,352 KB
testcase_12 AC 82 ms
15,280 KB
testcase_13 AC 82 ms
15,164 KB
testcase_14 AC 83 ms
15,148 KB
testcase_15 AC 82 ms
15,276 KB
testcase_16 AC 84 ms
15,352 KB
testcase_17 AC 84 ms
15,148 KB
testcase_18 AC 84 ms
15,260 KB
testcase_19 AC 82 ms
15,160 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/usr/bin/ruby
def perm
	r=0
	A.size.times{|i|
		(i+1..A.size-1).each{|j|
			r+=1 if A[i]>A[j]
		}
	}
	r
end
a=$<.map{|e|e.split.map(&:to_i)}
A=[]
parity=nil
4.times{|y|4.times{|x|
	k=a[y][x]
	if k>0
		A<<k
		k-=1
		ty,tx=k.divmod(4)
		d=(y-ty).abs+(x-tx).abs
		if d>1
			puts :No
			exit
		end
	else
		tx=ty=3
		parity=(y-ty).abs
	end
}}
puts [:Yes,:No][(perm+parity)%2]
0