Bzoj 4004 vector quasi-array

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.