提交记录 20607


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

template<int RADIX_LEN=8,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 #11.317 s1074 MB + 272 KBMemory Limit ExceededScore: 0


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