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 |
自制next_permutation() 400+MS过 //这里可以用2分查找进行优化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