猫猫爱画画 3
1 Sec 64 MB | Markdown 显示标签
一般 (*1400) 差分 前缀和 离散化
22 | 128 |
通过 | 提交 |
题目描述
Strange things happened again! Cosmic-Cat has been out of control since he learned to draw. However, he can't draw in a sense, it just rolls on the paper tape.
The tape can be seen as a number axis, the positions are numbered from left to right starting from $1$.
Cosmic-Cat will roll $N$ times, starting from the $L$ position on the paper tape to the $R$ position each time, and paint a layer of color on this interval of tape. He is having a good time, but now he wonders how long the tape is covered with exactly $x$ layers of color.
For each $x$ in the range of $[1,n]$, you need to tell cat the corresponding answer! Otherwise, cat will cry sadly!
---
奇怪的事情又发生了!星际猫自从学会画画后便一发不可收拾。
然而猫猫在某种意义上并不会画画,它只会在纸带上打滚。
纸带可以看作一段数轴,位置自左向右从 $1$ 开始编号。
猫猫会打滚 $N$ 次,每次会从纸带上的 $L$ 位置开始一直滚到 $R$ 位置,并且往这一段纸带上涂一层颜料。
猫猫玩得很开心,但它现在又想知道,有多长的纸带被涂上了 $x$ 层颜料。
对于 $[1,n]$ 范围内的每个 $x$,你都需要告诉猫猫对应的答案哦!不然猫猫会很伤心,哭唧唧~
输入格式
The first line contains a single integer $N$.
Next $N$ lines, each line contains two integers $L_i,R_i$, representing the left and right endpoints of the $i$-th rolling interval.
$1\le N\le 30000$
$1\le L_i\lt R_i\le 10^{18}$
---
第一行一个正整数 $N$,表示打滚的次数。
第 $2$ 行至第 $N+1$ 行,每行两个正整数 $L_i,R_i$,表示第 $i$ 次打滚的左右端点。
输出格式
Print $N$ lines, each line print a single integer. Line $i$ indicates the length of the paper tape covered with the color of exactly $x$ layer.
---
输出 $N$ 行,每行一个整数,第 $x$ 行表示被涂上了 $x$ 层颜料的纸带长度。
样例输入 #1
3 1 4 2 4 5 8
样例输出 #1
4 2 0
提示
Clarification for Sample:
Cosmic-Cat rolled three times: $[1,4],[2,4],[5,8]$.
The unit interval painted with $1$ layer of color is $[1,2],[5,6],[6,7],[7,8]$;
The unit interval painted with $2$ layers of color is $[2,3],[3,4]$;
There is no unit interval painted with $3$ layers of color.
---
对于样例,猫猫打滚了 $3$ 次:$[1,4],[2,4],[5,8]$。
涂了一层颜料的单位区间有 $[1,2],[5,6],[6,7],[7,8]$,共 $4$ 段;
涂了两层颜料的单位区间有 $[2,3],[3,4]$,共 $2$ 段;
没有涂了三层颜料的单位区间。
![1667621622364.png](/userfiles/images/d5e94eb6-23f9-402c-88ab-3072a2b388b3.png)