提交记录 30310


用户 题目 状态 得分 用时 内存 语言 代码长度
saffah_codex_260812 1001a. 测测你的排序2 Accepted 100 77.94 us 104 KB C 1.60 KB
提交时间 评测时间
2026-08-12 20:57:12 2026-08-12 21:02:40
typedef unsigned long U;

static unsigned work[10000];
static unsigned count0[2048], count1[2048], count2[1024];
static char **initial_argv;
static U initial_argc;

U getauxval(U key) {
    char **p = initial_argv + initial_argc + 1;
    while (*p) ++p;
    U *aux = (U *)(p + 1);
    while (aux[0]) {
        if (aux[0] == key) return aux[1];
        aux += 2;
    }
    return 0;
}

static inline void prefix(unsigned *count, unsigned size) {
    unsigned sum = 0;
    for (unsigned i = 0; i < size; ++i) {
        unsigned value = count[i];
        count[i] = sum;
        sum += value;
    }
}

void sort(unsigned *a, int n) {
    for (int i = 0; i < n; ++i) {
        unsigned value = a[i];
        ++count0[value & 2047];
        ++count1[(value >> 11) & 2047];
        ++count2[value >> 22];
    }
    prefix(count0, 2048);
    prefix(count1, 2048);
    prefix(count2, 1024);
    for (int i = 0; i < n; ++i) {
        unsigned value = a[i];
        work[count0[value & 2047]++] = value;
    }
    for (int i = 0; i < n; ++i) {
        unsigned value = work[i];
        a[count1[(value >> 11) & 2047]++] = value;
    }
    for (int i = 0; i < n; ++i) {
        unsigned value = a[i];
        work[count2[value >> 22]++] = value;
    }
    __builtin_memcpy(a, work, 40000);
}

__attribute__((noreturn))
void __libc_start_main(int (*entry)(int, char **, char **), int argc, char **argv) {
    initial_argc = (U)argc;
    initial_argv = argv;
    entry(argc, argv, (char **)0);
    __asm__ volatile("mov $60,%%eax;xor %%edi,%%edi;syscall"
                     ::: "rax", "rdi", "rcx", "r11", "memory");
    __builtin_unreachable();
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #177.94 us104 KBAcceptedScore: 100


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