Submission #21317848


Source Code Expand

Copy
h, w, x, y = gets.chomp.split(' ').map(&:to_i)
array = h.times.map { gets.chomp.split('').unshift('#') }
array.unshift([])
masu = array[x][y]

result = 0

x.times do |i| # 自分含む
  break if array[x-i][y] == "#"
  result += 1
end
(h-x).times do |i|
  n = i+1
  break if array[x+n][y] == "#"
  result += 1
end

y.times do |i| # 自分含む
  break if array[x][y-i] == "#"
  result += 1
end

(w-y).times do |i|
  n = i+1
  break if array[x][y+n] == "#"
  result += 1
end

puts result-1 # 重複した自分の分

Submission Info

Submission Time
Task B - Visibility
User aiandrox
Language Ruby (2.7.1)
Score 200
Code Size 546 Byte
Status AC
Exec Time 60 ms
Memory 14612 KB

Compile Error

./Main.rb:4: warning: assigned but unused variable - masu

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 32
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All extreme_00.txt, extreme_01.txt, extreme_02.txt, extreme_03.txt, extreme_04.txt, extreme_05.txt, extreme_06.txt, extreme_07.txt, handmade_00.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, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
extreme_00.txt AC 59 ms 14488 KB
extreme_01.txt AC 60 ms 14492 KB
extreme_02.txt AC 59 ms 14436 KB
extreme_03.txt AC 58 ms 14420 KB
extreme_04.txt AC 57 ms 14472 KB
extreme_05.txt AC 60 ms 14336 KB
extreme_06.txt AC 58 ms 14516 KB
extreme_07.txt AC 59 ms 14444 KB
handmade_00.txt AC 59 ms 14168 KB
random_00.txt AC 56 ms 14044 KB
random_01.txt AC 58 ms 14084 KB
random_02.txt AC 59 ms 14612 KB
random_03.txt AC 59 ms 14428 KB
random_04.txt AC 58 ms 14468 KB
random_05.txt AC 59 ms 14340 KB
random_06.txt AC 59 ms 14488 KB
random_07.txt AC 59 ms 14320 KB
random_08.txt AC 58 ms 14488 KB
random_09.txt AC 58 ms 14416 KB
random_10.txt AC 58 ms 14236 KB
random_11.txt AC 59 ms 14076 KB
random_12.txt AC 59 ms 14288 KB
random_13.txt AC 60 ms 14080 KB
random_14.txt AC 59 ms 14140 KB
random_15.txt AC 59 ms 14316 KB
random_16.txt AC 57 ms 14144 KB
random_17.txt AC 58 ms 14140 KB
random_18.txt AC 58 ms 14080 KB
random_19.txt AC 59 ms 14188 KB
sample_01.txt AC 57 ms 14228 KB
sample_02.txt AC 57 ms 14076 KB
sample_03.txt AC 58 ms 14220 KB