Created
September 9, 2018 05:56
-
-
Save whatalnk/ebc3e8554d01f3fb89139406b2c7f11f to your computer and use it in GitHub Desktop.
AtCoder ABC #109 D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h, w = gets.chomp.split(" ").map(&:to_i) | |
a = [] | |
h.times do | |
a << gets.chomp.split(" ").map(&:to_i) | |
end | |
ans = [] | |
h.times do |i| | |
w.times do |j| | |
if (a[i][j]).odd? | |
if j < w - 1 | |
a[i][j] -= 1 | |
a[i][j+1] += 1 | |
ans << [i+1, j+1, i+1, j+2] | |
else | |
if i < h - 1 | |
a[i][j] -= 1 | |
a[i+1][j] += 1 | |
ans << [i+1, j+1, i+2, j+1] | |
end | |
end | |
end | |
end | |
end | |
puts ans.length | |
ans.each{|line| puts line.join(" ")} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment