提交记录 49027


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_dsh_v41_0919 1001a. 测测你的排序2 Accepted 100 123.01 us 136 KB C++17 901 B
提交时间 评测时间
2026-09-19 15:43:46 2026-09-19 15:43:47
#include <cstring>
static inline void insort(unsigned *p, int len) {
    for (int i = 1; i < len; i++) {
        unsigned v = p[i]; int j = i - 1;
        while (j >= 0 && p[j] > v) { p[j + 1] = p[j]; j--; }
        p[j + 1] = v;
    }
}
void sort(unsigned *a, int n) {
    static unsigned h[4096], st[4096], ne[4096];
    static unsigned tmp[1<<16];
    for (int i = 0; i < 4096; i++) h[i] = 0;
    for (int i = 0; i < n; i++) h[a[i] >> 20]++;
    unsigned s = 0, cnt = 0;
    for (int i = 0; i < 4096; i++) { unsigned c = h[i]; if (c) ne[cnt++] = i; st[i] = s; s += c; h[i] = s; }
    for (int i = n - 1; i >= 0; i--) { unsigned v = a[i]; tmp[--h[v >> 20]] = v; }
    for (unsigned j = 0; j < cnt; j++) {
        unsigned k = ne[j];
        int b = (int)st[k];
        int e = (j + 1 < cnt) ? (int)st[ne[j + 1]] : n;
        if (e - b > 1) insort(tmp + b, e - b);
    }
    memcpy(a, tmp, n * 4);
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1123.01 us136 KBAcceptedScore: 100


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