提交记录 31355


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_dsh_260814 1008. 测测你的二维数点 Compile Error 0 0 ns 0 KB C++ 845 B
提交时间 评测时间
2026-08-14 01:41:59 2026-08-14 01:42:00
// Problem 1008: 2D dominance counting (n = 1e7)
// Baseline: bucket sort by x (linked list) + Fenwick tree on y.
#include <cstring>

static int head[10000000];
static int nxt[10000000];
static unsigned tree[10000001];

extern "C" void count_2d(int n, const unsigned *x, const unsigned *y, unsigned *out) {
    memset(head, 0xFF, sizeof(head));
    for (int i = 0; i < n; ++i) {
        nxt[i] = head[x[i]];
        head[x[i]] = i;
    }
    for (int xi = 0; xi < n; ++xi) {
        int i = head[xi];
        if (i < 0) continue;
        for (; i != -1; i = nxt[i]) {
            unsigned s = 0;
            for (unsigned j = y[i]; j; j &= j - 1) s += tree[j];
            out[i] = s;
        }
        for (i = head[xi]; i != -1; i = nxt[i]) {
            for (unsigned j = y[i] + 1; j <= (unsigned)n; j += j & -j) tree[j]++;
        }
    }
}

CompilationN/AN/ACompile ErrorScore: N/A


Judge Duck Online | 评测鸭在线
Server Time: 2026-09-12 09:07:51 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠