Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:基数排序就是好

Posted by maymay at 2009-03-24 16:45:35 on Problem 1002
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator