提交记录 19079


用户 题目 状态 得分 用时 内存 语言 代码长度
wys 1009a. 测测你的三维数点2 Accepted 100 575.312 ms 2752 KB C++ 1.53 KB
提交时间 评测时间
2023-02-06 04:55:59 2023-02-06 04:56:01
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

#include <cstring>
#include <algorithm>

struct E { int x, id; };

static bool cmp_e(const E &a, const E &b) {
    return a.x < b.x;
}

void count_3d(int n, const unsigned *x, const unsigned *y, const unsigned *z, unsigned *out) {
    const unsigned *x_in[3] = {x, y, z};
    E *e = new E[n];
    for (int i = 0; i < n; i++) {
        e[i].x = x_in[0][i];
        e[i].id = i;
    }
    std::sort(e, e + n, cmp_e);
    unsigned *xx[3];
    for (int i = 1; i < 3; i++) {
        xx[i] = new unsigned[n];
        for (int j = 0; j < n; j++) {
            xx[i][j] = x_in[i][e[j].id];
        }
    }
    int *max_j = new int[n];
    int tmp_j = 0;
    for (int i = 0; i < n; i++) {
        while (e[tmp_j].x < e[i].x) tmp_j++;
        max_j[i] = tmp_j;
    }
    unsigned *tmp_out = new unsigned[n];
    memset(tmp_out, 0, n * sizeof(unsigned));

    const int bi = 1024, bj = 1024;
    for (int ii = 0; ii < n; ii += bi) {
        int is = ii, ie = std::min(ii + bi, n);
        for (int jj = 0; jj < n; jj += bj) {
            int js = jj, je = std::min(jj + bj, n);

            for (int i = is; i < ie; i++) {
                int jee = std::min(je, max_j[i]);
                int oi = tmp_out[i];
                #pragma GCC unroll(8)
                for (int j = js; j < jee; j++) {
                    oi += xx[1][i] > xx[1][j] & xx[2][i] > xx[2][j];
                }
                tmp_out[i] = oi;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        out[e[i].id] = tmp_out[i];
    }
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1575.312 ms2 MB + 704 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2024-05-18 22:24:08 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用