提交记录 19049


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah 1009b. 测测你的三维数点3 Compile Error 0 0 ns 0 KB C++ 980 B
提交时间 评测时间
2023-02-05 23:43:29 2023-02-05 23:43:30
/*
测测你的三维数点3
时间限制: 5 s
空间限制: 2097152 KB

题目描述
三维空间中有 n 个点,每个点分别具有 [0, n) 整数范围的 x 坐标、y 坐标和 z 坐标(不同点的各维坐标值可能重复,即可能存在 x[i] == x[j] 或 y[i] == y[j] 或 z[i] == z[j])。你需要对每个点,统计每维坐标均小于该点对应维坐标的点的个数。

接口
void count_3d(int n, const unsigned *x, const unsigned *y, const unsigned *z, unsigned *out);

其中,第 i (0 <= i < n) 个点的坐标为 (x[i], y[i], z[i]),其统计结果需要保存到 out[i]。

数据范围
n 等于 10,000
*/

#include <tuple>
#include <vector>
using namespace std;

void count_3d(int n, const unsigned *x, const unsigned *y, const unsigned *z, unsigned *out) {
    vector<tuple<unsigned, unsigned, unsigned>> v;
    v.reserve(n);
    for (int i = 0; i < n; i++)
        v.emplace_back(x[i], y[i], z[i]);
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++) {
        int tmp = 0;
        for (int j = 0; j < n; j++) {
            if (get<0>(v[j]) < get<0>(v[i]) && get<1>(v[j]) < get<1>(v[i]) && get<2>(v[j]) < get<2>(v[i])) {
                ++tmp;
            }
        }
        out[i] = tmp;
    }
}

CompilationN/AN/ACompile ErrorScore: N/A


Judge Duck Online | 评测鸭在线
Server Time: 2025-09-16 04:53:15 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠