提交记录 9391


用户 题目 状态 得分 用时 内存 语言 代码长度
Crossing 1001. 测测你的排序 Runtime Error 0 525.666 ms 391540 KB C++11 1.27 KB
提交时间 评测时间
2019-05-06 07:36:28 2020-08-01 01:37:30
// #include "interactor.h"
#include <cstdio>
#include <algorithm>

// 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, maxv = 1 << 8;

void sort(unsigned int *a, int n) {
    int cnt1[maxv], cnt2[maxv], cnt3[maxv], cnt4[maxv];
    unsigned int 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 OKScore: N/A

Testcase #1525.666 ms382 MB + 372 KBRuntime ErrorScore: 0


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