提出 #19978760


ソースコード 拡げる

N,W = gets.split.map(&:to_i)
S = $<.map(&:chomp)*''
s = i = 0
while i = S.index(?#,i+1)
	s += 3 if [-W-1,-W,-1].all?{|j| S[i+j]==?. }
	s += 3 if [-W,-W+1,1].all?{|j| S[i+j]==?. }
	s += 3 if [-1,W-1,W].all?{|j| S[i+j]==?. }
	s += 3 if [1,W,W+1].all?{|j| S[i+j]==?. }
	s += 1 if S[i-W-1]==?. && [-W,-1].all?{|j| S[i+j]==?# }
	s += 1 if S[i-W+1]==?. && [-W,1].all?{|j| S[i+j]==?# }
	s += 1 if S[i+W-1]==?. && [-1,W].all?{|j| S[i+j]==?# }
	s += 1 if S[i+W+1]==?. && [1,W].all?{|j| S[i+j]==?# }
	s += 1 if S[i-W]==?. && [-W-1,-1].all?{|j| S[i+j]==?# }
	s += 1 if S[i-W]==?. && [-W+1,1].all?{|j| S[i+j]==?# }
	s += 1 if S[i-1]==?. && [-W-1,-W].all?{|j| S[i+j]==?# }
	s += 1 if S[i-1]==?. && [W-1,W].all?{|j| S[i+j]==?# }
	s += 1 if S[i+1]==?. && [-W,1-W].all?{|j| S[i+j]==?# }
	s += 1 if S[i+1]==?. && [W,W+1].all?{|j| S[i+j]==?# }
	s += 1 if S[i+W]==?. && [-1,W-1].all?{|j| S[i+j]==?# }
	s += 1 if S[i+W]==?. && [1,W+1].all?{|j| S[i+j]==?# }
end
p s/3

提出情報

提出日時
問題 C - Digital Graffiti
ユーザ ds14050
言語 Ruby (2.7.1)
得点 300
コード長 969 Byte
結果 AC
実行時間 62 ms
メモリ 14484 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 1
AC × 27
セット名 テストケース
Sample sample_01.txt
All handmade_00.txt, handmade_01.txt, handmade_02.txt, handmade_03.txt, oldsample_00.txt, oldsample_01.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, sample_01.txt
ケース名 結果 実行時間 メモリ
handmade_00.txt AC 62 ms 14128 KiB
handmade_01.txt AC 61 ms 14228 KiB
handmade_02.txt AC 59 ms 14188 KiB
handmade_03.txt AC 61 ms 14452 KiB
oldsample_00.txt AC 57 ms 14292 KiB
oldsample_01.txt AC 61 ms 14308 KiB
random_00.txt AC 60 ms 14064 KiB
random_01.txt AC 59 ms 14376 KiB
random_02.txt AC 61 ms 14268 KiB
random_03.txt AC 61 ms 14172 KiB
random_04.txt AC 61 ms 14260 KiB
random_05.txt AC 57 ms 14140 KiB
random_06.txt AC 62 ms 14260 KiB
random_07.txt AC 55 ms 14188 KiB
random_08.txt AC 59 ms 14088 KiB
random_09.txt AC 60 ms 14484 KiB
random_10.txt AC 60 ms 14156 KiB
random_11.txt AC 60 ms 14256 KiB
random_12.txt AC 60 ms 14120 KiB
random_13.txt AC 59 ms 14308 KiB
random_14.txt AC 57 ms 14340 KiB
random_15.txt AC 60 ms 14224 KiB
random_16.txt AC 61 ms 14208 KiB
random_17.txt AC 60 ms 14240 KiB
random_18.txt AC 60 ms 14108 KiB
random_19.txt AC 60 ms 14236 KiB
sample_01.txt AC 59 ms 14316 KiB