提交记录 20630


用户 题目 状态 得分 用时 内存 语言 代码长度
platelet 1001. 测测你的排序 Compile Error 0 0 ns 0 KB C++17 1018 B
提交时间 评测时间
2023-11-29 20:02:31 2023-11-29 20:02:33
#include <bits/stdc++.h>

using namespace std;

const int n = 1e8;

template <class T>
void F(uint* a, uint* b, T lambda) {
    uint *p[256];
    for (int i = 0; i < 256; i++) p[i] = b + n / 256 * i * 2;
    for (int i = 0; i < n; i++) *p[lambda(a[i])]++ = a[i];
    auto ptr = a;
    for (int k = 0; k < 256; k++) {
        auto len = p[k] - (b + n / 256 * k * 2);
        memcpy(ptr, b + n / 256 * k * 2, len * sizeof(uint));
        ptr += len;
    }
}

void sort(uint* a, int __n) {
    uint* b = (uint*)malloc(n * sizeof(uint) * 2);
    F(a, b, [](uint x) { return x & 255; });
    F(a, b, [](uint x) { return x >> 8 & 255; });
    F(a, b, [](uint x) { return x >> 16 & 255; });
    F(a, b, [](uint x) { return x >> 24; });
}
int main() {
    uint* a = (uint*)malloc(n * sizeof(uint));
    uint* b = (uint*)malloc(n * sizeof(uint));
    mt19937 gen;
    for (int i = 0; i < n; i++) a[i] = gen();
    memcpy(b, a, n * 4);
    sort(a, n), sort(b, b + n);
    if (memcmp(a, b, n * 4))
        cout << "wa" << endl;
}

CompilationN/AN/ACompile ErrorScore: N/A


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