提交记录 15613


用户 题目 状态 得分 用时 内存 语言 代码长度
wawcac wc2017b1. 【WC2017】挑战-任务1 Accepted 100 2.097 s 1562528 KB C++ 1.78 KB
提交时间 评测时间
2021-01-02 02:58:37 2021-01-02 02:58:42
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 #1975.26 us808 KBAcceptedScore: 34

Testcase #21.048 s762 MB + 992 KBAcceptedScore: 33

Testcase #32.097 s1525 MB + 928 KBAcceptedScore: 33


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