提交记录 20610


用户 题目 状态 得分 用时 内存 语言 代码长度
TSKY 1001. 测测你的排序 Memory Limit Exceeded 0 3.231 s 1200876 KB C++14 814 B
提交时间 评测时间
2023-11-28 18:11:47 2023-11-28 18:11:55
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
using namespace std;

template<int RADIX_LEN=16,typename Iter>
void radix_sort(Iter begin,Iter end)
{
    using DataTy=uint32_t;
    constexpr int RADIX = 1<<RADIX_LEN;
    static_assert(sizeof(DataTy)==4);
    std::array<std::vector<DataTy>,RADIX> bucket;
    for(int i=0;i<32/RADIX_LEN;i++)
    {
        for(auto it=begin;it!=end;++it)
        {
            DataTy num=*it;
            bucket[(num>>i*RADIX_LEN)%RADIX].push_back(num);
        }
        auto it=begin;
        for(auto &&v:bucket)
        {
            for(auto num:v)
            {
                *it=num;
                ++it;
            }
            v.clear();
        }
        //bucket.clear();
    }
}

void sort(unsigned *a, int n) {
	radix_sort(a, a + n);
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #13.231 s1172 MB + 748 KBMemory Limit ExceededScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2025-09-12 19:08:24 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠