#GD0000090. Quá nhiều đoạn – bản khó (Too Many Segments (hard version))
Bài tập thuộc lộ trình
Mục lục đề ⌄
Quá nhiều đoạn – bản khó (Too Many Segments (hard version))
Too Many Segments (hard version)
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You have inclusive integer intervals indexed from to . An integer coordinate is overloaded if more than retained intervals cover it. Remove the minimum number of intervals so that no integer point is overloaded, outputting the count and indices removed. Intervals may overlap or coincide.
Input
The first line contains . Each of the next lines contains .
Output
Print the minimum number of removed intervals and then distinct one-based indices in any order. The second line may be empty if .
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
5 1
1 3
3 5
4 6
7 8
2 4
Output
2
5 2
Explanation
With , keep intervals , , and , removing intervals and . The retained intervals are pairwise disjoint at all integer points. At least two removals are necessary because three of the original intervals mutually intersect.