当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6521:Party

题目描述
$n$ person have just entered a company, and Xiaoxun, as a supervisor, gives each of them a number from 1 to n that is not repeated.

In order to let them to get to know each other better, they would have a party every day, and there was a limit on the number of people at each party. Xiaoxun didn't want to find a way to find people randomly. So every time he had a party, he would only invite people with numbers in a certain interval to play.

The people who come to the party will get to know each other, and Xiaoxun wants to know how effective each party is. The effect is evaluated as the number of pairs of people at this party who did not appear at the same previous party.
输入解释
There are mutiple test cases.

Each case starts with a line containing two integers $n,m (n\leq 5\times10^5,m\leq5\times 10^5)$which represent the number of people and the number of parties. And this is followed by $m$ lines each containing two integers $l,r(1\leq l\leq r\leq n)$ which mean the interval, and only the people whose number in the interval can take part in this party.
输出解释
For each case you should print $m$ lines.

Each line containing a integer mean the effect of this party.
输入样例
5 4
1 2
4 5
1 4
2 5
输出样例
1
1
5
2
提示
explaination of sample:

The first party: 1-2

The second party: 4-5

The third party: 1-3 1-4 2-3 2-4 3-4

The fourth party: 2-5 3-5
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6521

最后修改于 2020-10-25T23:32:04+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 65536/65536K(Java/Others)