提交记录 10561


用户 题目 状态 得分 用时 内存 语言 代码长度
wys 1001. 测测你的排序 Accepted 100 800.424 ms 781276 KB C++11 934 B
提交时间 评测时间
2019-09-19 10:29:55 2020-08-01 02:17:07
#include <string.h>

void sort(unsigned *a, int n){
	unsigned *b = new unsigned[n];
	unsigned cnt1[256], cnt2[256], cnt3[256], cnt4[256];
	memset(cnt1, 0, sizeof(cnt1));
	memset(cnt2, 0, sizeof(cnt2));
	memset(cnt3, 0, sizeof(cnt3));
	memset(cnt4, 0, sizeof(cnt4));
	
	for (int i = 0; i < n; i++) {
		unsigned tmp = a[i];
		cnt1[tmp & 255]++;
		cnt2[(tmp >> 8) & 255]++;
		cnt3[(tmp >> 16) & 255]++;
		cnt4[tmp >> 24]++;
	}
	
	for (int i = 1; i < 256; i++) {
		cnt1[i] += cnt1[i - 1];
		cnt2[i] += cnt2[i - 1];
		cnt3[i] += cnt3[i - 1];
		cnt4[i] += cnt4[i - 1];
	}
	
	for (int i = n - 1; i >= 0; i--) {
		unsigned x = a[i];
		b[--cnt1[x & 255]] = x;
	}
	
	for (int i = n - 1; i >= 0; i--) {
		unsigned x = b[i];
		a[--cnt2[(x >> 8) & 255]] = x;
	}
	
	for (int i = n - 1; i >= 0; i--) {
		unsigned x = a[i];
		b[--cnt3[(x >> 16) & 255]] = x;
	}
	
	for (int i = n - 1; i >= 0; i--) {
		unsigned x = b[i];
		a[--cnt4[x >> 24]] = x;
	}
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1800.424 ms762 MB + 988 KBAcceptedScore: 100


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