Solving the Rt.
EPS = 1e-10 wronganswer
EPS = 1e-5 Accepted
1 /**************************************************************2 problem:40043 user:idy0024 language:c++5 result:accepted6 time:516 Ms7 memory:2844 KB8 ****************************************************************/9 Ten#include <cstdio> One#include <cstring> A#include <algorithm> - #defineEPS 1e-5 - #defineN 510 the using namespacestd; - - intN, M; - DoubleAa[n][n]; + intCost[n]; - intVid[n]; + intKid[n]; A at intsgDoublex) { - return(x>-eps)-(x<EPS); - } - BOOLcmpintAintb) {returncost[a]<cost[b];} - BOOLJoinintID) { - for(intI=1; i<=m; i++ ) { in if(SG (aa[id][i]) = =0)Continue; - if(kid[i]==0 ) { tokid[i]=ID; + return true; - } the intUID =Kid[i]; * DoubleK = aa[id][i]/Aa[uid][i]; $ for(intJ=i; j<=m; J + + )Panax NotoginsengAA[ID][J]-= k*Aa[uid][j]; - } the return false; + } A intMain () { thescanf"%d%d", &n, &m); + for(intI=1; i<=n; i++ ) - for(intj=1; j<=m; J + + ) $scanf"%LF", &aa[i][j]); $ for(intI=1; i<=n; i++ ) -scanf"%d", cost+i); - for(intI=1; i<=n; i++ ) theVid[i] =i; -Sort (vid+1, vid+1+N, CMP);WuyiMemset (Kid,0,sizeof(Kid)); the intCnt=0, ans=0; - for(intI=1; i<=n; i++ ) { Wu intID =Vid[i]; - if(Join (ID)) { Aboutcnt++; $ans+=Cost[id]; - } - } -printf"%d%d\n", CNT, ans); A}
View Code
Bzoj 4004 vector quasi-array