提交记录 27362


用户 题目 状态 得分 用时 内存 语言 代码长度
recadend8 wc2017b1. 【WC2017】挑战-任务1 Time Limit Exceeded 67 3 s 1563028 KB C++17 867 B
提交时间 评测时间
2024-11-18 11:54:46 2024-11-18 11:54:54
#include <algorithm>
#include <array>
#include <vector>

void sort(unsigned* a, int n) {
    constexpr int BASE_WIDTH = 16;
    constexpr unsigned BASE = 1 << BASE_WIDTH;

    auto cursors = std::array<std::array<int, BASE>, 2>();
    for (int i = 0; i < n; i++) {
        cursors[0][a[i] & (BASE - 1)]++;
        cursors[1][(a[i] >> BASE_WIDTH) & (BASE - 1)]++;
    }

    for (int iter = 0; iter < 2; iter++) {
        int prefix_offset = 0;
        for (unsigned v = 0; v < BASE; v++) {
            std::swap(prefix_offset, cursors[iter][v]);
            prefix_offset += cursors[iter][v];
        }
    }

    auto buffer = new unsigned[n];

    for (int i = 0; i < n; i++) {
        buffer[cursors[0][a[i] & (BASE - 1)]++] = a[i];
    }
    for (int i = 0; i < n; i++) {
        a[cursors[1][buffer[i] >> BASE_WIDTH]++] = buffer[i];
    }

    delete[] buffer;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #11.599 ms1 MB + 288 KBAcceptedScore: 34

Testcase #22.938 s763 MB + 472 KBAcceptedScore: 33

Testcase #33 s1526 MB + 404 KBTime Limit ExceededScore: 0


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