提交记录 15892


用户 题目 状态 得分 用时 内存 语言 代码长度
worstcoder 1001. 测测你的排序 Compile Error 0 0 ns 0 KB C++ 1.08 KB
提交时间 评测时间
2021-02-26 22:52:16 2021-02-26 22:52:17
#include <cstring>
const int N = 100000000 + 5;
int aux[N];
void sort(int *a, int n) {
	    // wys radix sort
    const int U = 256;
    int cnt[U];
    memset(cnt, 0, sizeof cnt);
    for (int i = 0; i < n; ++i)
        ++cnt[a[i] & U - 1];
    for (int i = 1; i < U; ++i)
        cnt[i] += cnt[i - 1];
    for (int i = n - 1; i >= 0; --i)
        aux[--cnt[a[i] & U - 1]] = a[i];
    memset(cnt, 0, sizeof cnt);
    for (int i = 0; i < n; ++i)
        ++cnt[aux[i] >> 8 & U - 1];
    for (int i = 1; i < U; ++i)
        cnt[i] += cnt[i - 1];
    for (int i = n - 1; i >= 0; --i)
        a[--cnt[aux[i] >> 8 & U - 1]] = aux[i];
    memset(cnt, 0, sizeof cnt);
    for (int i = 0; i < n; ++i)
        ++cnt[a[i] >> 16 & U - 1];
    for (int i = 1; i < U; ++i)
        cnt[i] += cnt[i - 1];
    for (int i = n - 1; i >= 0; --i)
        aux[--cnt[a[i] >> 16 & U - 1]] = a[i];
    memset(cnt, 0, sizeof cnt);
    for (int i = 0; i < n; ++i)
        ++cnt[aux[i] >> 24];
    for (int i = 1; i < U; ++i)
        cnt[i] += cnt[i - 1];
    for (int i = n - 1; i >= 0; --i)
        a[--cnt[aux[i] >> 24]] = aux[i];
}

CompilationN/AN/ACompile ErrorScore: N/A


Judge Duck Online | 评测鸭在线
Server Time: 2026-03-20 02:49:34 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠