比赛 |
EYOI暨SBOI暑假快乐赛3rd |
评测结果 |
AWWAWTTTTTTTTTTTTTTT |
题目名称 |
Convoluted Intervals |
最终得分 |
10 |
用户昵称 |
cb |
运行时间 |
46.196 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2022-06-27 10:15:52 |
显示代码纯文本
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, m, ans[10005] = {0}, c[10005] = {0};
int a[200005], b[200005];
int lowbit (int x) {
return (x & -x);
}
void add (int x, int y) {
for (; x <= (m << 1); x += lowbit (x)) {
c[x] += y;
}
return ;
}
ll ask (int x) {
ll ans = 0;
for (; x; x -= lowbit (x)) {
ans += c[x];
}
return ans;
}
int main () {
freopen ("Convoluted_Intervals.in", "r", stdin);
freopen ("Convoluted_Intervals.out", "w", stdout);
scanf ("%d %d", &n, &m);
for (int q = 1; q <= n; ++q) {
scanf ("%d %d", &a[q], &b[q]);
for (int w = 1; w <= q; ++w) {
int aa, bb;
aa = a[q] + a[w]; bb = b[q] + b[w];
aa ++; bb ++;
if (q == w) {
add (aa, 1); add (bb + 1, -1);
}
else {
add (aa, 2); add (bb + 1, -2);
}
}
}
for (int q = 1; q <= (m << 1) + 1; ++ q) {
printf ("%lld\n", ask (q));
}
return 0;
}