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:my program seems quite slow then i expected :( , is that any wrong?In Reply To:first sort by profit, then try whether a product can be arranged Posted by:dynamic at 2003-11-01 20:57:15 // the following is the union set part, if arrange == 0 , then can't insert any more if == -1, can insert (empty) else traverse forward to find an empty slot~ path compression is already implemented, why still so slow ? bool insert(int d) { if (arrange[d] == 0) return false; if (arrange[d] == -1) { arrange[d] = d-1; return true; } else { int t = arrange[d]; while (t > 0 && arrange[t] != -1) { t = arrange[t]; } while (d > 0 && d != t) { int k = arrange[d]; arrange[d] = t; d = k; } if (arrange[t] == -1) { arrange[t] = t-1; return true; } else { return false; } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator