提交记录 15589


用户 题目 状态 得分 用时 内存 语言 代码长度
wawcac wc2017b1. 【WC2017】挑战-任务1 Runtime Error 0 1.977 s 1745624 KB C++ 1.29 KB
提交时间 评测时间
2021-01-02 02:15:04 2021-01-02 02:15:08
void sort(unsigned *a, int n)
{
    unsigned *b=new unsigned[n];
	unsigned *ptr0[256],*ptr8[256],*ptr16[256],*ptr24[256];
	unsigned cnt0[256], cnt8[256], cnt16[256], cnt24[256];
    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;)
    {
        ++cnt0[a[i] & 255], ++cnt8[a[i] >> 8 & 255], ++cnt16[a[i] >> 16 & 255], ++cnt24[a[i] >> 24], ++i;
        ++cnt0[a[i] & 255], ++cnt8[a[i] >> 8 & 255], ++cnt16[a[i] >> 16 & 255], ++cnt24[a[i] >> 24], ++i;
        ++cnt0[a[i] & 255], ++cnt8[a[i] >> 8 & 255], ++cnt16[a[i] >> 16 & 255], ++cnt24[a[i] >> 24], ++i;
        ++cnt0[a[i] & 255], ++cnt8[a[i] >> 8 & 255], ++cnt16[a[i] >> 16 & 255], ++cnt24[a[i] >> 24], ++i;
    }
    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[0]>>k&255]=a[0];\
    *++ptr##k[a[1]>>k&255]=a[1];\
    *++ptr##k[a[2]>>k&255]=a[2];\
    *++ptr##k[a[3]>>k&255]=a[3];\
}

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

CompilationN/AN/ACompile OKScore: N/A

Testcase #1995.2 us896 KBRuntime ErrorScore: 0

Testcase #21.155 s803 MB + 224 KBWrong AnswerScore: 0

Testcase #31.977 s1704 MB + 728 KBRuntime ErrorScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2026-03-20 14:45:46 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠