{"id":583,"date":"2019-02-03T23:10:13","date_gmt":"2019-02-03T15:10:13","guid":{"rendered":"http:\/\/SmokeyDays.top\/wordpress\/?p=583"},"modified":"2019-02-03T23:10:13","modified_gmt":"2019-02-03T15:10:13","slug":"lp2604-zjoi2010-%e7%bd%91%e7%bb%9c%e6%89%a9%e5%ae%b9","status":"publish","type":"post","link":"http:\/\/SmokeyDays.top\/wordpress\/2019\/02\/03\/lp2604-zjoi2010-%e7%bd%91%e7%bb%9c%e6%89%a9%e5%ae%b9\/","title":{"rendered":"lp2604 ZJOI2010 \u7f51\u7edc\u6269\u5bb9"},"content":{"rendered":"\n<p>\u7b2c\u4e00\u95ee\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684\u3002\u76f4\u63a5\u770b\u7b2c\u4e8c\u95ee\u3002<br>\n\u4e00\u4e2a\u5f88\u76f4\u63a5\u7684\u60f3\u6cd5\u5c31\u662f\uff0c\u5728\u6bcf\u6761\u8fb9\u4e0a\u90fd\u52a0\u4e0a\u4e00\u6761\u5bb9\u91cf\u4e3a\\(k\\)\uff0c\u8d39\u7528\u4e3a\\(c_{e}\\)\u7684\u8fb9\u3002<br>\n\u4f46\u662f\u4ed4\u7ec6\u4e00\u60f3\u4f1a\u53d1\u73b0\u4e00\u4e2a\u95ee\u9898\uff1a\u5982\u679cs\u5230t\u6709\u591a\u6761\u8def\u5f84\u7684\u8bdd\uff0c\u4e0a\u8ff0\u7684\u65b9\u6cd5\u5c31\u4f1a\u4f7f\u5f97\u6d41\u91cf\u603b\u989d\u8fc7\u5927\u3002<br>\n\u6709\u4ec0\u4e48\u597d\u65b9\u6cd5\u5462\uff1f<br>\n\u7b2c\u4e00\u4e2a\u76f4\u63a5\u7684\u60f3\u6cd5\u662f\u53d1\u73b0\u6e90\u6c47\u4e4b\u95f4\u5982\u679c\u6709\u591a\u6761\u8def\u5f84\u7684\u8bdd\uff0c\u90a3\u4e48\u5fc5\u7136\u662f\u5c06\u6240\u6709\u7684\u6d41\u91cfk\u5168\u90fd\u8d2a\u5fc3\u5730\u653e\u5728\u82b1\u8d39\u6700\u5c0f\u7684\u90a3\u6761\u8def\u5f84\u4e0a\u662f\u6700\u4f18\u7684\u3002 <br>\n\u4f46\u662f\u8fd9\u663e\u7136\u662f\u4e0d\u53ef\u80fd\u7684\uff0c\u8003\u8651\u4e00\u4e2a\u6b8b\u4f59\u7f51\u7edc\u975e\u7a7a\u7684\u60c5\u51b5\u3002<br>\n\u6545\u800c\u6211\u4eec\u6362\u4e00\u79cd\u601d\u8def\uff1a\u5728\u539f\u6765\u6240\u6709\u8fb9\u4e0a\u989d\u5916\u8fde\u6d41\u91cf\u4e3ak\u7684\u8fb9\u7684\u540c\u65f6\uff0c\u518d\u4ecen\u5411\u4e00\u4e2a\u865a\u62df\u6c47\u70b9t\u8fde\u4e00\u6761\u8fb9\u3002\u8fd9\u6837\u65e2\u53ef\u5b8c\u6210\u3002 <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream>\n#include&lt;cstdio>\n#include&lt;queue>\n\nconst int INF = 0x3f3f3f3f;\ninline int Min(int A,int B){\n\treturn A&lt;B?A:B;\n}\nstruct ee{\n\tint v;\n\tint w;\n\tint c;\n\tint nxt;\n}e[20005];\nint h[20005],et=-1;\ninline void Eadd(int U,int V,int W,int C){\n\te[++et]=(ee){V,W,C,h[U]};\n\th[U]=et;\n}\ninline void add(int U,int V,int W,int C){\n\tEadd(U,V,W,C);\n\tEadd(V,U,0,-C);\n}\nint n,m,s,t,K,dis[20005],nw[20005],val[20005],fa[20005],vis[20005];\nint u[20005],v[20005],w[20005],c[20005];\nstd::queue&lt;int> q;\ninline bool SPFA(){\n\tfor(int i=1;i&lt;=t;++i){\n\t\tdis[i]=INF;\n\t\tval[i]=INF;\n\t\tvis[i]=0;\n\t}\n\tq.push(s);\n\tdis[s]=0,vis[s]=1,fa[t]=-1;\n\tint p;\n\twhile(!q.empty()){\n\t\tp=q.front();\n\t\tq.pop();\n\t\tvis[p]=0;\n\t\tfor(int i=h[p];i>=0;i=e[i].nxt){\n\t\t\tif(dis[e[i].v]>dis[p]+e[i].c&amp;&amp;e[i].w>0){\n\t\t\t\tdis[e[i].v]=dis[p]+e[i].c;\n\t\t\t\tfa[e[i].v]=p;\n\t\t\t\tnw[e[i].v]=i;\n\t\t\t\tval[e[i].v]=Min(e[i].w,val[p]);\n\t\t\t\tif(!vis[e[i].v]){\n\t\t\t\t\tvis[e[i].v]=1;\n\t\t\t\t\tq.push(e[i].v);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn fa[t]!=-1;;\n}\n\nint answ=0,ansc=0;\ninline void EK(){\n\tint p;\n\twhile(SPFA()){\n\t\tp=t;\n\t\tansw+=val[t];\n\t\tansc+=val[t]*dis[t];\n\t\twhile(p!=s){\n\t\t\te[nw[p]].w-=val[t];\n\t\t\te[nw[p]^1].w+=val[t];\n\t\t\tp=fa[p];\n\t\t}\n\t} \n}\n\n\nvoid init(){\n\tscanf(\"%d%d%d\",&amp;n,&amp;m,&amp;K);\n\ts=1,t=n;\n\tfor(int i=1;i&lt;=n+1;++i){\n\t\th[i]=-1;\n\t}\n\tfor(int i=1;i&lt;=m;++i){\n\t\tscanf(\"%d%d%d%d\",u+i,v+i,w+i,c+i);\n\t\tadd(u[i],v[i],w[i],0);\n\t}\n\tEK();\n\tprintf(\"%d \",answ);\n\tfor(int i=1;i&lt;=m;++i){\n\t\tadd(u[i],v[i],INF,c[i]);\n\t}\n\tadd(t,t+1,K,0);\n\t++t;\n\tEK();\n\tprintf(\"%d\\n\",ansc);\n}\n\nint main(){\n\tinit();\n\treturn 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7b2c\u4e00\u95ee\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684\u3002\u76f4\u63a5\u770b\u7b2c\u4e8c\u95ee\u3002 \u4e00\u4e2a\u5f88\u76f4\u63a5\u7684\u60f3\u6cd5\u5c31\u662f\uff0c\u5728\u6bcf\u6761\u8fb9\u4e0a\u90fd\u52a0\u4e0a\u4e00\u6761\u5bb9\u91cf\u4e3a\\(k\\)\uff0c\u8d39\u7528\u4e3a\\(c_ &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/SmokeyDays.top\/wordpress\/2019\/02\/03\/lp2604-zjoi2010-%e7%bd%91%e7%bb%9c%e6%89%a9%e5%ae%b9\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201clp2604 ZJOI2010 \u7f51\u7edc\u6269\u5bb9\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[76,8,9,6,75,5],"tags":[],"_links":{"self":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/583"}],"collection":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/comments?post=583"}],"version-history":[{"count":1,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/583\/revisions"}],"predecessor-version":[{"id":584,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/583\/revisions\/584"}],"wp:attachment":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/media?parent=583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/categories?post=583"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/tags?post=583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}