Testing Round 6
B
Optimizer
Codeforces
2100
原题
← AC →
翻译中…

A process RAM is a sequence of bytes that are indexed from 1 to $*n*$. Polycarpus's program contains such instructions as "memset", that is, the operations of filling memory cells on a segment with some value. The details are: the code only contains $*m*$ instructions that look like "set13 a_i l_i". Instruction $*i*$ fills a continuous memory segment of length $*l*_{*i*}$, starting from cell number $*a*_{*i*}$, (that it cells with numbers $*a*_{*i*}, *a*_{*i*} + 1, ..., *a*_{*i* + *l*_{*i*} - 1}$) with values 13.

翻译中…

In Polycarpus's code, the optimizer's task is to remove the maximum number of instructions from his code in such a way that the remaining instructions set value 13 in all the memory bytes that got this value from the code before the optimization. Also, the value 13 should be set only in the memory bytes that got this value from the code before the optimization. Your task is to implement the optimizer for such program.

翻译中…

Input

翻译中…

The first line contains integers $*n*$ and $*m*$ ($1 ≤ *n* ≤ 2·10^{6}, 1 ≤ *m* ≤ 2·10^{5}$) — the number of bytes (memory cells) and the number of instructions in Polycarpus's code. Then $*m*$ lines follow, each line contains a pair of integers $*a*_{*i*}$, $*l*_{*i*}$ ($1 ≤ *a*_{*i*} ≤ *n*, 1 ≤ *l*_{*i*} ≤ *n* - *a*_{*i*} + 1$).

翻译中…

Output

翻译中…

Print in the first line the sought maximum number of instructions that can be removed from the code. In the second line print the numbers of the instructions. The instructions are numbered from 1 to $*m*$ in the order they appeared in the input. If there are multiple solutions, print any of them.

翻译中…

样例

Input #1
10 4
3 3
3 1
4 1
9 2
Output #1
2
2 3
InputCopy OutputCopy
Input #2
1 1
1 1
Output #2
0
InputCopy OutputCopy
题目信息
题号
306B
所属比赛
时间限制
3 s
内存限制
256 MB
标签
数据结构
贪心
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。