結果

問題 No.228 ゆきこちゃんの 15 パズル
ユーザー cielciel
提出日時 2015-11-01 03:53:49
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 361 bytes
コンパイル時間 70 ms
コンパイル使用メモリ 11,476 KB
実行使用メモリ 15,320 KB
最終ジャッジ日時 2023-10-11 07:41:51
合計ジャッジ時間 2,805 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 85 ms
15,144 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 82 ms
15,144 KB
testcase_14 AC 83 ms
15,196 KB
testcase_15 AC 81 ms
15,116 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 84 ms
15,172 KB
testcase_19 AC 84 ms
15,084 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:26: warning: assigned but unused variable - parity
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=[]
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