#include<string.h>
#include<algorithm>
void sort(unsigned *a, int n){
#define N 10000
#define D 256
#define D1 255
#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 bub[N+1],*rs[D],t0[D],t1[D],t2[D],t3[D];
#define b (bub+1)
b[-1]=0;
register unsigned*p,i,x;
for(i=0;i<D;++i){
t0[i]=0;
t1[i]=0;
t2[i]=0;
t3[i]=0;
}
for(i=0;i<N;){
#define A x=a[i];++t1[x>>8&D1];++t2[x>>16&D1];++t3[x>>24];++i;
A A A A
}
cal(a,b,t1,>>8&D1);
cal(b,a,t2,>>16&D1);
cal(a,b,t3,>>24);
for(i=0;i<256;++i){for(int j=i;b[j]<b[j-1];--j)std::swap(b[j],b[j-1]);}
for(;i<N;++i){for(int j=i;b[j]<b[j-1];--j)std::swap(b[j],b[j-1]);a[i-256]=b[i-256];}
for(;i<N+256;++i){a[i-256]=b[i-256];}
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 64.1 us | 92 KB | Accepted | Score: 100 | 显示更多 |