提交记录 12351


用户 题目 状态 得分 用时 内存 语言 代码长度
Simpson561 1001. 测测你的排序 Accepted 100 717.77 ms 762 MB + 1000 KB C 2.10 KB
提交时间 评测时间
2020-03-23 14:26:40 2020-03-23 14:26:45
#define N 100000000
#define D 256
#define D1 255
unsigned *rs[D],t0[D],t1[D],t2[D],t3[D];
void count_t(unsigned*a){
	asm volatile(R"(
		xorl %%ecx,%%ecx
		movl %[a],%%esi
		0:
			movl (%%esi,%%ecx,4),%%eax
			incl %%ecx
			movl (%%esi,%%ecx,4),%%ebx
			incl %%ecx
			
			movzbl %%al,%%edx
			movzbl %%bl,%%edi
			incl %[t0](,%%edx,4)
			incl %[t0](,%%edi,4)
			
			movzbl %%ah,%%edx
			movzbl %%bh,%%edi
			incl %[t1](,%%edx,4)
			incl %[t1](,%%edi,4)
			
			shrl $16,%%eax
			shrl $16,%%ebx
			movzbl %%al,%%edx
			movzbl %%bl,%%edi
			incl %[t2](,%%edx,4)
			incl %[t2](,%%edi,4)
			
			movzbl %%ah,%%edx
			movzbl %%bh,%%edi
			incl %[t3](,%%edx,4)
			incl %[t3](,%%edi,4)
			
			cmpl $100000000,%%ecx
			jne 0b
	)"
	:
	:[a]"m"(a),[t0]"m"(t0),[t1]"m"(t1),[t2]"m"(t2),[t3]"m"(t3)
	:"memory","eax","ebx","ecx","edx","esi","edi"
	); 
}
void sort_0(unsigned*a,unsigned*b){
	rs[0]=b;
	for(int i=1;i<D;++i)rs[i]=rs[i-1]+t0[i-1];
	asm volatile(R"(
		xorl %%ecx,%%ecx
		movl %[a],%%esi
		0:
			movl (%%esi),%%eax
			movl 4(%%esi),%%ebx
			movzbl %%al,%%edx
			movzbl %%bl,%%ebp
			
			movl %[rs](,%%edx,4),%%edi
			movl %%eax,(%%edi)
			addl $4,%[rs](,%%edx,4)
			
			movl %[rs](,%%ebp,4),%%edi
			movl %%ebx,(%%edi)
			addl $4,%[rs](,%%ebp,4)
			
			movl 8(%%esi),%%eax
			movl 12(%%esi),%%ebx
			movzbl %%al,%%edx
			movzbl %%bl,%%ebp
			
			movl %[rs](,%%edx,4),%%edi
			movl %%eax,(%%edi)
			addl $4,%[rs](,%%edx,4)
			
			movl %[rs](,%%ebp,4),%%edi
			movl %%ebx,(%%edi)
			addl $4,%[rs](,%%ebp,4)
			
			addl $16,%%esi
			addl $4,%%ecx
			
			cmpl $100000000,%%ecx
			jne 0b
	)"
	:
	:[a]"m"(a),[t0]"m"(t0),[rs]"m"(rs)
	:"memory","eax","ebx","ecx","edx","esi","edi","ebp"
	);
}
void sort(unsigned*a,int n){
#define cal(w,w2,tw,op) \
p=w2-1;\
for(i=0;i<D;++i)rs[i]=p,p+=tw[i];\
for(i=0;i<N;i+=8){\
	p=w+i;\
	*++rs[p[0]op]=p[0],\
	*++rs[p[1]op]=p[1],\
	*++rs[p[2]op]=p[2],\
	*++rs[p[3]op]=p[3],\
	*++rs[p[4]op]=p[4],\
	*++rs[p[5]op]=p[5],\
	*++rs[p[6]op]=p[6],\
	*++rs[p[7]op]=p[7];\
}
unsigned b[N],*p,i,x;
count_t(a);
sort_0(a,b);
//sort_1(b,a);
//sort_2(a,b);
//sort_3(b,a);
//cal(a,b,t0,&D1);
cal(b,a,t1,>>8&D1);
cal(a,b,t2,>>16&D1);
cal(b,a,t3,>>24);
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1717.77 ms762 MB + 1000 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2020-04-06 09:03:05 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用