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

而且相差也太大了!用自带的qsort运行时间是407MS,自己写的快排居然2000MS Timeout。

Posted by yinyueyouge at 2008-03-07 17:32:52 on Problem 1002
In Reply To:Re:无语,自己写的快排就是没有自带的快,一换qsort就过…… Posted by:yinyueyouge at 2008-03-07 17:25:41
差距那么大么?

我写的快排:

void swap(int *a, int *b) {
    int t=*a; *a=*b; *b=t;
}

void quickSort(int arr[], int beg, int end) {
    if (end > beg + 1) {
        int piv = arr[beg], l = beg + 1, r = end;
        while (l < r) {
            if (arr[l] <= piv)
                l++;
            else
                swap(&arr[l], &arr[--r]);
        }
        swap(&arr[--l], &arr[beg]);
        quickSort(arr, beg, l);
        quickSort(arr, r, end);
    }
}

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