Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created April 14, 2019 04:25
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/131371c56173b0d23fc636ab0ba1a95c to your computer and use it in GitHub Desktop.
Save whatalnk/131371c56173b0d23fc636ab0ba1a95c to your computer and use it in GitHub Desktop.
Codeforces #551 Div2 B - Serval and Toy Bricks
n, m, h = gets.chomp.split(" ").map(&:to_i)
front = gets.chomp.split(" ").map(&:to_i)
left = gets.chomp.split(" ").map(&:to_i)
top = []
n.times do
top << gets.chomp.split(" ").map(&:to_i)
end
ret = Array.new(n){Array.new(m, -1)}
m.times do |i|
n.times do |j|
ret[j][i] = front[i]
end
end
n.times do |j|
m.times do |i|
ret[j][i] = [ret[j][i], left[j]].min
end
end
m.times do |i|
n.times do |j|
if top[j][i] == 0
ret[j][i] = 0
end
end
end
ret.each{|line| puts line.join(" ")}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment