Submission #524461


Source Code Expand

Copy
require 'set'

n, m = gets.split.map &:to_i

buckets = (0..n+1).map{ [] }

queue = []
(1..m).each{|i|
    s, t = gets.split.map &:to_i
    buckets[s] << [s, :start, i]
    buckets[t+1] << [t+1, :end, i]
}
queue = buckets.flatten(1)
indices = Set.new
ng = {}

until queue.empty?
    x = queue[0][0]
    while !queue.empty? && queue[0][0] == x
        _, event, i = queue.shift
        if event == :start
            indices << i
        else
            indices.delete(i)
        end
    end
    ng[indices.to_a[0]] = 1 if indices.size == 1
end

p m - ng.size
(1..m).each{|i| p i unless ng[i]}

Submission Info

Submission Time
Task B - ドキドキデート大作戦高橋君
User QtaroKujo
Language Ruby (2.1.5p273)
Score 100
Code Size 624 Byte
Status
Exec Time 1856 ms
Memory 75500 KB

Compile Error

./Main.rb:3: warning: `&' interpreted as argument prefix
./Main.rb:9: warning: `&' interpreted as argument prefix
./Main.rb:31: warning: shadowing outer local variable - i

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt
Subtask1 30 / 30 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt
All 70 / 70 subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt 69 ms 5348 KB
subtask0_sample_02.txt 67 ms 5348 KB
subtask0_sample_03.txt 67 ms 5344 KB
subtask1_01.txt 894 ms 43628 KB
subtask1_02.txt 1718 ms 75500 KB
subtask1_03.txt 868 ms 40720 KB
subtask1_04.txt 1358 ms 49100 KB
subtask1_05.txt 1330 ms 49100 KB
subtask1_06.txt 66 ms 5352 KB
subtask1_07.txt 68 ms 5356 KB
subtask1_08.txt 69 ms 5356 KB
subtask1_09.txt 66 ms 5352 KB
subtask2_01.txt 1719 ms 68700 KB
subtask2_02.txt 1856 ms 67180 KB
subtask2_03.txt 74 ms 5352 KB
subtask2_04.txt 72 ms 5352 KB
subtask2_05.txt 72 ms 5352 KB
subtask2_06.txt 70 ms 5352 KB
subtask2_07.txt 72 ms 5352 KB
subtask2_08.txt 1782 ms 50292 KB