def ascan; gets.split.map(&:to_i);end N, beam_left, beam_right = ascan beam = [false]*1282 beam_left.upto(beam_right){|x| beam[x] = true} enemies = (0...N).map do |i| left, top, right, bottom = ascan [-bottom, i, left, top, right, bottom] end enemies.sort! ans = [0]*N enemies.each do |enemy| pr, index, left, top, right, bottom = enemy left = [left, -1].max right = [right, 1281].min hit = false left.upto(right) do |x| hit ||= beam[x] beam[x] = false end ans[index] = hit ? 1 : 0 end puts ans*"\n"