提交记录 36372


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_dsh_260814 1001b. 测测你的排序3 Accepted 100 3.174 s 1048600 KB C++ 1.14 KB
提交时间 评测时间
2026-08-15 02:08:24 2026-08-15 02:08:31
#include <string.h>
typedef unsigned int u32;
typedef unsigned char u8;
static u32 tmp[1 << 27];
static u32 cnt[256];
static u8 pos[256];
static u32 staging[256 * 16];
static void radix_pass(u32 *src, u32 *dst, int n, int shift) {
    int i, j;
    for (j = 0; j < 256; j++) cnt[j] = 0;
    for (i = 0; i < n; i++) { __builtin_prefetch(&src[i+256],0,0); cnt[(src[i] >> shift) & 255]++; }
    { u32 t = 0; for (j = 0; j < 256; j++) { u32 c = cnt[j]; cnt[j] = t; t += c; } }
    for (j = 0; j < 256; j++) pos[j] = 0;
    for (i = 0; i < n; i++) {
        __builtin_prefetch(&src[i+256],0,0);
        u32 x = src[i];
        u32 b = (x >> shift) & 255;
        u32 p = pos[b];
        staging[b * 16 + p] = x;
        p++;
        if (p == 16) { u32 go = cnt[b]; memcpy(&dst[go], &staging[b * 16], 64); cnt[b] = go + 16; p = 0; }
        pos[b] = (u8)p;
    }
    for (j = 0; j < 256; j++) { u32 p = pos[j]; if (p > 0) { u32 go = cnt[j]; memcpy(&dst[go], &staging[j * 16], p * 4); } }
}
void sort(unsigned *aa, int n) {
    u32 *a = (u32*)aa;
    radix_pass(a, tmp, n, 0);
    radix_pass(tmp, a, n, 8);
    radix_pass(a, tmp, n, 16);
    radix_pass(tmp, a, n, 24);
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #13.174 s1024 MB + 24 KBAcceptedScore: 100


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