提交记录 9389


用户 题目 状态 得分 用时 内存 语言 代码长度
Crossing 1001. 测测你的排序 Compile Error 0 0 ns 0 KB C++11 1.28 KB
提交时间 评测时间
2019-05-06 07:32:24 2020-08-01 01:37:13
// #include "interactor.h"
#include <cstdio>
#include <algorithm>
#define u32 unsigned int

// inline u32 read() {
//     u32 x = 0; char c = getchar();
//     for (; c < 48 || c > 57; c = getchar());
//     for (; c >= 48 && c <= 57; c = getchar()) x = ((x + (x << 2)) << 1) + (c ^ 48);
//     return x;
// }
//0xff : 1111 1111
const int N = 3e7 + 2;

inline void sort(unsigned int *a, int n) {
    int cnt1[1 << 8], cnt2[1 << 8], cnt3[1 << 8], cnt4[1 << 8];
    u32 b[N];
    for (int i = 0; i < n; ++i) {
        ++cnt1[a[i] & 0xff];
        ++cnt2[(a[i] >> 8) & 0xff];
        ++cnt3[(a[i] >> 16) & 0xff];
        ++cnt4[a[i] >> 24];
    }
    for (int i = 1; i <= 0xff; ++i) {
        cnt1[i] += cnt1[i - 1];
        cnt2[i] += cnt2[i - 1];
        cnt3[i] += cnt3[i - 1];
        cnt4[i] += cnt4[i - 1];
    }
    for (int i = n - 1; ~i; --i)
        b[--cnt1[a[i] & 0xff]] = a[i];
    for (int i = n - 1; ~i; --i)
        a[--cnt2[(b[i] >> 8) & 0xff]] = b[i];
    for (int i = n - 1; ~i; --i)
        b[--cnt3[(a[i] >> 16) & 0xff]] = a[i];
    for (int i = n - 1; ~i; --i)
        a[--cnt4[b[i] >> 24]] = b[i];
}

// int main() {
//     n = read();
//     for (int i = 0; i < n; ++i) a[i] = read();
//     sort(a, n);
//     for (int i = 0; i < n; ++i) printf("%d ", a[i]); puts("");
//     return 0;
// }

CompilationN/AN/ACompile ErrorScore: N/A


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