提交记录 15587


用户 题目 状态 得分 用时 内存 语言 代码长度
wawcac wc2017b1. 【WC2017】挑战-任务1 Runtime Error 0 662.467 ms 781280 KB C++ 1.30 KB
提交时间 评测时间
2021-01-02 02:13:06 2021-01-02 02:13:07
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[p[0] & 255] = p[0];\
    *++ptr##k[p[1] & 255] = p[1];\
    *++ptr##k[p[2] & 255] = p[2];\
    *++ptr##k[p[3] & 255] = p[3];\
}

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

CompilationN/AN/ACompile OKScore: N/A

Testcase #1344.73 us420 KBRuntime ErrorScore: 0

Testcase #2331.235 ms381 MB + 508 KBRuntime ErrorScore: 0

Testcase #3662.467 ms762 MB + 992 KBRuntime ErrorScore: 0


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