| 比赛 | EYOI暨SBOI暑假快乐赛3rd | 评测结果 | AAAAAAAAAAAAAAAAAAAA | 
    | 题目名称 | Convoluted Intervals | 最终得分 | 100 | 
    | 用户昵称 | ムラサメ | 运行时间 | 1.536 s | 
    | 代码语言 | C++ | 内存使用 | 0.00 MiB | 
    | 提交时间 | 2022-06-27 10:58:30 | 
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull a[200005],b[200005],c[200005];
ull n,m;
int main(){
	freopen("Convoluted_Intervals.in","r",stdin);
	freopen("Convoluted_Intervals.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	ull a1,b1;
	for(int i=1;i<=n;i++){
		cin>>a1>>b1;
		a[a1]++;
		b[b1]++; 
	}
	for(int i=0;i<=m;i++){
		for(int j=0;j<=m;j++){
			c[i+j]+=a[i]*a[j];
			c[i+j+1]-=b[i]*b[j];
		}
	}
	ull cnt=0;
	for(int i=0;i<=m*2;i++){
		cnt+=c[i];
		cout<<cnt<<endl;
	}
	return 0;
}