Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created November 6, 2016 16:12
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/0d0513a0586b78986ad2c7a9ea6178b5 to your computer and use it in GitHub Desktop.
Save whatalnk/0d0513a0586b78986ad2c7a9ea6178b5 to your computer and use it in GitHub Desktop.
AtCoder ABC #047 [Ruby]
a, b, c = gets.chomp.split(" ").map(&:to_i)
if (a + b == c) || (b + c == a) || (c + a == b) then
puts "Yes"
else
puts "No"
end
w, h, n = gets.chomp.split(" ").map(&:to_i)
mm = Array.new(h){Array.new(w, true)}
n.times do
x, y, a = gets.chomp.split(" ").map(&:to_i)
x -= 1
y -= 1
case a
when 1
h.times do |i|
w.times do |j|
mm[i][j] = false if j <= x
end
end
when 2
h.times do |i|
w.times do |j|
mm[i][j] = false if j > x
end
end
when 3
h.times do |i|
if i <= y then
mm[i] = [false] * w
end
end
when 4
h.times do |i|
if i > y then
mm[i] = [false] * w
end
end
end
end
puts mm.flatten.count{|x| x}
s = gets.chomp
n = s.length
ret = 0
(1..(n-1)).each do |i|
if s[i] != s[i-1] then
ret += 1
end
end
puts ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment