CF306B.Optimizer

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A process RAM is a sequence of bytes that are indexed from 1 to nn . 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 mm instructions that look like "set13 a_i l_i". Instruction ii fills a continuous memory segment of length lil_{i} , starting from cell number aia_{i} , (that it cells with numbers ai,ai+1,...,ai+li1a_{i},a_{i}+1,...,a_{i+li}-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.

输入格式

The first line contains integers nn and mm ( 1<=n<=2106,1<=m<=21051<=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 mm lines follow, each line contains a pair of integers aia_{i} , lil_{i} ( 1<=ai<=n,1<=li<=nai+11<=a_{i}<=n,1<=l_{i}<=n-a_{i}+1 ).

输出格式

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 mm in the order they appeared in the input. If there are multiple solutions, print any of them.

输入输出样例

  • 输入#1

    10 4
    3 3
    3 1
    4 1
    9 2
    

    输出#1

    2
    2 3 
  • 输入#2

    1 1
    1 1
    

    输出#2

    0
    
首页