Last active
October 11, 2015 08:38
-
-
Save whatalnk/dad3a4d335753f7fc785 to your computer and use it in GitHub Desktop.
ARC #045
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
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(" ") |
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
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