結果

問題 No.585 工夫のないパズル
ユーザー cielciel
提出日時 2017-10-29 22:05:48
言語 Ruby
(3.3.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 875 bytes
コンパイル時間 352 ms
コンパイル使用メモリ 11,540 KB
実行使用メモリ 15,276 KB
最終ジャッジ日時 2023-08-14 09:54:54
合計ジャッジ時間 3,067 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,256 KB
testcase_01 AC 81 ms
15,160 KB
testcase_02 AC 84 ms
15,200 KB
testcase_03 AC 82 ms
15,164 KB
testcase_04 AC 80 ms
15,124 KB
testcase_05 AC 81 ms
15,052 KB
testcase_06 AC 81 ms
15,128 KB
testcase_07 AC 81 ms
15,072 KB
testcase_08 AC 81 ms
15,196 KB
testcase_09 AC 79 ms
15,268 KB
testcase_10 AC 80 ms
15,204 KB
testcase_11 AC 80 ms
15,052 KB
testcase_12 AC 80 ms
15,048 KB
testcase_13 AC 81 ms
15,160 KB
testcase_14 AC 80 ms
15,276 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:16: warning: assigned but unused variable - mse
Main.rb:28: warning: assigned but unused variable - sy0
Main.rb:28: warning: assigned but unused variable - sy1
Main.rb:28: warning: assigned but unused variable - sy
Syntax OK

ソースコード

diff #

R=[]
class Array
def rotR(r,n)
	R<<'R %d %d'%[r,n];a=self.dup;a[r]=a[r].rotate(-n);a
end
def rotD(c,n)
	R<<'C %d %d'%[c,n];a=self.transpose;a[c]=a[c].rotate(-n);a.transpose
end
def search(n)
	4.times{|y|4.times{|x|return [x,y] if self[y][x]==n}}
end
def sw(c)
	k=3;self.rotD(c,1).rotR(k,1).rotD(c,3).rotR(k,2).rotD(c,1).rotR(k,1).rotD(c,3).rotR(k,1)
end
end
m=$<.map{|e|e.chomp.chars.map{|c|c.ord-65}};mss=12;mse=16
mss.times{|i|
	sx,sy=m.search i;ty,tx=i.divmod 4
	if sx==tx
		next if sy==ty;m=m.rotR sy,1;sx=-~sx%4
	end
	if sy==ty
		m=m.rotD(sx,1).rotD(tx,1).rotR(sy+1,(tx-sx)%4).rotD(sx,3).rotD(tx,3)
	else
		m=m.rotD(tx,sy-ty).rotR(sy,(tx-sx)%4).rotD(tx,4-sy+ty)
	end
}
sx0,sy0=m.search mss;sx1,sy1=m.search mss+1;(sx0-sx1)%4==1&&m=m.sw(sx0+1);(sx0-sx1)%4==2&&m=m.sw(sx1+1);sx,sy=m.search mss;sx!=0&&m=m.rotR(3,4-sx);sx0,sy0=m.search mss+2;sx0!=2&&m.sw(0);p R.size;puts R
0