Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created September 17, 2018 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/c32b110b0035620a85bf6819d60f40bb to your computer and use it in GitHub Desktop.
Save whatalnk/c32b110b0035620a85bf6819d60f40bb to your computer and use it in GitHub Desktop.
AtCoder ABC #045 D
# ABC045 D
h, w, n = gets.chomp.split(" ").map(&:to_i)
hash = Hash.new(0)
n.times do
a, b = gets.chomp.split(" ").map(&:to_i)
a -= 1
b -= 1
(a-2).upto(a) do |i|
(b-2).upto(b) do |j|
if i >= 0 && i + 2 < h && j >= 0 && j + 2 < w
x = [i, j]
hash[x] += 1
end
end
end
end
ans = Array.new(10, 0)
s = 0
hash.each do |k, v|
ans[v] += 1
s += 1
end
ans[0] = (h - 2) * (w - 2) - s
ans.each{|x| puts x}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment