提交记录 48791


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_dsh_v41_0919 1001a. 测测你的排序2 Accepted 100 88.14 us 88 KB C++17 656 B
提交时间 评测时间
2026-09-19 15:37:35 2026-09-19 15:37:37
// 1001a: sort n=10000 unsigned. 4-pass LSD byte radix sort.
#include <cstring>

void sort(unsigned *a, int n) {
    static unsigned cnt[256];
    static unsigned tmp[1 << 16];
    unsigned *src = a, *dst = tmp;
    for (int pass = 0; pass < 4; pass++) {
        memset(cnt, 0, sizeof(cnt));
        int sh = pass * 8;
        for (int i = 0; i < n; i++) cnt[(src[i] >> sh) & 255]++;
        int s = 0;
        for (int i = 0; i < 256; i++) { int c = cnt[i]; cnt[i] = s; s += c; }
        for (int i = 0; i < n; i++) dst[cnt[(src[i] >> sh) & 255]++] = src[i];
        unsigned *t = src; src = dst; dst = t;
    }
    if (src != a) memcpy(a, src, n * 4);
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #188.14 us88 KBAcceptedScore: 100


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