luogu#P1840. Color the Axis

    ID: 807 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>线段树并查集颜色段均摊(珂朵莉树 ODT)NOI 导刊分块

Color the Axis

Problem Description

On a number line there are nn points, namely 1,2,,n1, 2, \ldots, n. Initially, all points are colored black. Then we perform mm operations; in the ii-th operation, the points in [li,ri][l_i,r_i] are painted white. Output the number of black points remaining after each operation.

Input Format

The first line contains nn and mm. Each of the next mm lines contains two integers lil_i, rir_i.

Output Format

Output mm lines, where each line is the number of black points remaining after the corresponding operation.

10 3
3 3
5 7
2 8
9
6
3

Hint

  • For 30% of the testdata, 1n20001\le n\le 2000, 1m20001\le m\le 2000.
  • For 100% of the testdata, 1lirin2×1051\le l_i\le r_i\le n\le 2\times 10^5, 1m2×1051\le m\le 2\times 10^5.

Translated by ChatGPT 5