提交记录 16371


用户 题目 状态 得分 用时 内存 语言 代码长度
imalyd 1001. 测测你的排序 Accepted 100 890.982 ms 781264 KB C++ 1.10 KB
提交时间 评测时间
2021-07-22 12:57:08 2021-07-22 12:57:12
#include<cstddef>
namespace ya
{
	#define YA_RADIX_SORT_BASE 256
	#define YA_RADIX_SORT_LOOP(Begin,End,Begin2,End2,OP) \
	for(k=0;k!=YA_RADIX_SORT_BASE;++k)\
		Cnt[k]=0;\
	for(i=Begin;i!=End;++i)\
		++Cnt[OP(*i)];\
	i=Begin2;\
	for(k=0;k!=YA_RADIX_SORT_BASE;++k)\
		La[k]=(i+=Cnt[k]);\
	i=End;\
	do{\
		--i;\
		(*(--La[OP(*i)]))=(*i);\
	}while(i!=Begin);
	void radix_sort(unsigned int *Begin,unsigned int *End){
		size_t N(End-Begin),Cnt[YA_RADIX_SORT_BASE],k;
		unsigned int Begin2[N],*End2(Begin2+N),*La[YA_RADIX_SORT_BASE],*i;
		#define YA_RADIX_SORT_UNSIGNED_INT_OP1(x) ((x)&255u)
		#define YA_RADIX_SORT_UNSIGNED_INT_OP2(x) ((x)>>8&255u)
		#define YA_RADIX_SORT_UNSIGNED_INT_OP3(x) ((x)>>16&255u)
		#define YA_RADIX_SORT_UNSIGNED_INT_OP4(x) ((x)>>24)
		YA_RADIX_SORT_LOOP(Begin,End,Begin2,End2,YA_RADIX_SORT_UNSIGNED_INT_OP1);
		YA_RADIX_SORT_LOOP(Begin2,End2,Begin,End,YA_RADIX_SORT_UNSIGNED_INT_OP2);
		YA_RADIX_SORT_LOOP(Begin,End,Begin2,End2,YA_RADIX_SORT_UNSIGNED_INT_OP3);
		YA_RADIX_SORT_LOOP(Begin2,End2,Begin,End,YA_RADIX_SORT_UNSIGNED_INT_OP4);
	}
};
void sort(unsigned *a, int n){
	ya::radix_sort(a,a+n);
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1890.982 ms762 MB + 976 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2024-11-24 00:21:40 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠