Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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