| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:基数排序就是好In Reply To:基数排序就是好 Posted by:fanhqme at 2009-03-08 11:02:32 > int datas[datamax],tmpa[65536],tmpb[datamax],N;
> void raidxsort(){
> memset(tmpa,0,sizeof(tmpa));
> for (int i=0;i<N;++i)++tmpa[(datas[i]&65535)+1];
> for (int i=1;i<65536;++i)tmpa[i]+=tmpa[i-1];
> for (int i=0;i<N;++i)tmpb[tmpa[datas[i]&65535]++]=datas[i];
> memset(tmpa,0,sizeof(tmpa));
> for (int i=0;i<N;++i)++tmpa[(tmpb[i]>>16)+1];
> for (int i=1;i<65536;++i)tmpa[i]+=tmpa[i-1];
> for (int i=0;i<N;++i)datas[tmpa[tmpb[i]>>16]++]=tmpb[i];
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator