Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Last active October 11, 2015 08: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/dad3a4d335753f7fc785 to your computer and use it in GitHub Desktop.
Save whatalnk/dad3a4d335753f7fc785 to your computer and use it in GitHub Desktop.
ARC #045
s = gets.chomp.split(" ")
res = []
s.each do |i|
case i
when "Left" then res << "<"
when "Right" then res << ">"
when "AtCoder" then res << "A"
end
end
puts res.join(" ")
n, m = gets.chomp.split(" ").map(&:to_i)
rooms = Array.new(n+2, 0)
ranges = []
m.times do
s, t = gets.chomp.split(" ").map(&:to_i)
rooms[s] += 1
rooms[t+1] -= 1
ranges << [s, t]
end
n.times do |i|
rooms[i+1] += rooms[i]
end
rooms = rooms.map{|i|
if i > 1 then
0
else
i
end
}
n.times do |i|
rooms[i+1] += rooms[i]
end
res = []
ranges.each_with_index do |range, i|
if rooms[range[1]] - rooms[range[0]-1] == 0 then
res << i += 1
end
end
puts res.length
res.each{|i| p i}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment