CF1297I.Falling Blocks

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

The first line contains two integers nn and dd ( 1n,d1051 \le n, d \le 10^5 ) — the number of falling blocks and the length of the flat surface.

The ii -th of the following nn lines contains integers lil_i and rir_i ( 1lirid1 \le l_i \le r_i \le d ) — the coordinates of the ii -th block.

输入格式

Output nn integers. The ii -th integer should be the number of blocks that will be left after the ii -th block falls.

输出格式

The first example is explained above.

In the second example, this is what happens after each block falls:

  • Block 11 will stick to the flat surface.
  • Block 22 will stick to the flat surface.
  • Block 33 will stick to blocks 11 and 22 . Note that block 33 will not vaporize block 22 because it does not cover block 11 and is in contact with it.
  • Block 44 will vaporize all the blocks and stick to the flat surface.
  • Block 55 will stick to block 44
  • Block 66 will stick to block 55 .
  • Block 77 will stick to block 66 . Note that no blocks are vaporized because although block 77 covers block 44 and block 55 , they never come in contact.
  • Block 88 vaporizes block 77 and sticks to block 66 .

输入输出样例

  • 输入#1

    3 3
    1 2
    2 3
    1 3

    输出#1

    1
    2
    1
  • 输入#2

    8 6
    1 2
    3 3
    2 3
    1 3
    2 4
    3 6
    1 5
    1 5

    输出#2

    1
    2
    3
    1
    2
    3
    4
    4

说明/提示

The first example is explained above.

In the second example, this is what happens after each block falls:

  • Block 11 will stick to the flat surface.
  • Block 22 will stick to the flat surface.
  • Block 33 will stick to blocks 11 and 22 . Note that block 33 will not vaporize block 22 because it does not cover block 11 and is in contact with it.
  • Block 44 will vaporize all the blocks and stick to the flat surface.
  • Block 55 will stick to block 44
  • Block 66 will stick to block 55 .
  • Block 77 will stick to block 66 . Note that no blocks are vaporized because although block 77 covers block 44 and block 55 , they never come in contact.
  • Block 88 vaporizes block 77 and sticks to block 66 .
首页