Submission #5948427


Source Code Expand

H, W = gets.split.map(&:to_i)
c = []
H.times do
  c << gets.chomp
end
d = [[0, -1], [0, 1], [-1, 0], [1, 0]]
ans = "Yes"
H.times do |h|
  W.times do |w|
    if c[h][w] == "#"
      cnt = 0
      d.each do |(dx, dy)|
        if (0 <= w + dx && w + dx < W) && (0 <= h + dy && h + dy < H)
          cnt += (c[h + dy][w + dx] == "#" ? 1 : 0)
        end
      end
      ans = "No" if cnt == 0
    end
  end
end

puts ans

Submission Info

Submission Time
Task C - Grid Repainting 2
User qsako6
Language Ruby (2.3.3)
Score 300
Code Size 439 Byte
Status AC
Exec Time 12 ms
Memory 3836 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 13
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
in01.txt AC 12 ms 1788 KB
in02.txt AC 12 ms 1788 KB
in03.txt AC 8 ms 1788 KB
in04.txt AC 8 ms 1788 KB
in05.txt AC 12 ms 1788 KB
in06.txt AC 11 ms 1788 KB
in07.txt AC 11 ms 1788 KB
in08.txt AC 11 ms 1788 KB
in09.txt AC 10 ms 1788 KB
in10.txt AC 10 ms 1788 KB
sample_01.txt AC 7 ms 1788 KB
sample_02.txt AC 7 ms 1788 KB
sample_03.txt AC 7 ms 3836 KB