比赛 EYOI暨SBOI暑假快乐赛3rd 评测结果 AATTTTWWWWTTTWWTTTWT
题目名称 Convoluted Intervals 最终得分 10
用户昵称 lihaoze 运行时间 34.603 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2022-06-27 10:46:38
显示代码纯文本
#include <bits/stdc++.h>

using i64 = long long;
using PII = std::pair<int, int>;

const int N = 1e4+10;
int c[N], n, m;
PII a[N];

int lowbit(int x) { return x & -x; }

i64 ask(int x) {
    i64 y = 0;
    for (; x; x -= lowbit(x)) y += c[x];
    return y;
}
 
void insert(int x, int y) {
    for (; x < N; x += lowbit(x)) c[x] += y;
}

int main() {
    freopen("Convoluted_Intervals.in", "r", stdin); 
    freopen("Convoluted_Intervals.out", "w", stdout);
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cin >> n >> m;
    for (int i = 1; i <= n; ++ i) {
        auto& [x, y] = a[i];
        std::cin >> x >> y;
    }
    for (int i = 1; i <= n; ++ i) {
        for (int j = 1; j <= n; ++ j) {
            auto [x1, y1] = a[i]; 
            auto [x2, y2] = a[j];
            insert(x1 + x2, 1);
            insert(y1 + y2 + 1, -1);
        }
    }
    for (int i = 0; i <= 2 * m; ++ i) {
        std::cout << ask(i) << '\n';
    }
    return 0;
}