提交记录 16372


用户 题目 状态 得分 用时 内存 语言 代码长度
imalyd 1001a. 测测你的排序2 Accepted 100 74.48 us 88 KB C++ 1.10 KB
提交时间 评测时间
2021-07-22 14:51:01 2021-07-22 14:51:04
#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 #174.48 us88 KBAcceptedScore: 100


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