提交记录 19243


用户 题目 状态 得分 用时 内存 语言 代码长度
NaOH_Frog 1001c. 测测你的排序4 Accepted 100 16.134 s 1048604 KB C++ 1.80 KB
提交时间 评测时间
2023-02-27 19:10:17 2023-02-27 19:10:39
//NOT MY CODE!!!!!!!!!
void sort(unsigned *a, int n)
{
    unsigned *b=new unsigned[n];
#define sz 299
	unsigned *ptr0[sz],*ptr8[sz],*ptr16[sz],*ptr24[sz];
	unsigned cnt0[sz], cnt8[sz], cnt16[sz], cnt24[sz];
    unsigned *p;
    for (int i = 0; i < 256; ++i)
    {
        cnt0[i] = 0;
        cnt8[i] = 0;
        cnt16[i] = 0;
        cnt24[i] = 0;
    }
    for (int i = 0; i < n;i+=4){
        ++cnt0[a[i+0]&255], ++cnt8[a[i+0]>>8&255], ++cnt16[a[i+0]>>16&255], ++cnt24[a[i+0]>>24];
        ++cnt0[a[i+1]&255], ++cnt8[a[i+1]>>8&255], ++cnt16[a[i+1]>>16&255], ++cnt24[a[i+1]>>24];
        ++cnt0[a[i+2]&255], ++cnt8[a[i+2]>>8&255], ++cnt16[a[i+2]>>16&255], ++cnt24[a[i+2]>>24];
        ++cnt0[a[i+3]&255], ++cnt8[a[i+3]>>8&255], ++cnt16[a[i+3]>>16&255], ++cnt24[a[i+3]>>24];
    }
	switch(n&3){
	    case 3:++cnt0[a[n-2]&255], ++cnt8[a[n-2]>>8&255], ++cnt16[a[n-2]>>16&255], ++cnt24[a[n-2]>>24];
	    case 2:++cnt0[a[n-1]&255], ++cnt8[a[n-1]>>8&255], ++cnt16[a[n-1]>>16&255], ++cnt24[a[n-1]>>24];
	    case 1:++cnt0[a[n-0]&255], ++cnt8[a[n-0]>>8&255], ++cnt16[a[n-0]>>16&255], ++cnt24[a[n-0]>>24];
		default: break;
	}
    ptr0[0]=b-1,ptr8[0]=a-1,ptr16[0]=b-1,ptr24[0]=a-1;
    for (int i = 1; i < 256; ++i){
        ptr0[i] = ptr0[i-1]+cnt0[i-1];
		ptr8[i] = ptr8[i-1]+cnt8[i-1];
		ptr16[i] = ptr16[i-1]+cnt16[i-1];
		ptr24[i] = ptr24[i-1]+cnt24[i-1];
	}
#define countingSort(a,k) \
for (int i = 0; i < n; i += 4){\
    *++ptr##k[a[i+0]>>k&255]=a[i+0];\
    *++ptr##k[a[i+1]>>k&255]=a[i+1];\
    *++ptr##k[a[i+2]>>k&255]=a[i+2];\
    *++ptr##k[a[i+3]>>k&255]=a[i+3];\
}\
switch(n&3){\
    case 3:*++ptr##k[a[n-2]>>k&255]=a[n-2];\
    case 2:*++ptr##k[a[n-1]>>k&255]=a[n-1];\
    case 1:*++ptr##k[a[n=0]>>k&255]=a[n-0];\
	default: break;\
}

	countingSort(a,0);
	countingSort(b,8);
	countingSort(a,16);
	countingSort(b,24);
	delete[] b;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #116.134 s1024 MB + 28 KBAcceptedScore: 100


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