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:自制next_permutation() 400+MS过 //这里可以用2分查找进行优化In Reply To:自制next_permutation() 400+MS过 //这里可以用2分查找进行优化 Posted by:CydorniaKnight at 2009-02-25 14:57:06 > void NextPermutation() > { > int i,j,n1=n-1,k; > for(i=n1-1;i>=0;--i) > if(num[i]<num[i+1]) > break; > if(i<0){ > MegerSort(0,n); > return; > } > for(j=n1;j>=i+1;--j)//这里可以用2分查找进行优化 > if(num[j]>num[i]) > break; > k=num[i]; > num[i]=num[j]; > num[j]=k; > MegerSort(i+1,n); > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator