{"id":573,"date":"2019-01-28T20:08:17","date_gmt":"2019-01-28T12:08:17","guid":{"rendered":"http:\/\/SmokeyDays.top\/wordpress\/?p=573"},"modified":"2019-01-28T20:08:44","modified_gmt":"2019-01-28T12:08:44","slug":"lp2774-%e6%96%b9%e6%a0%bc%e5%8f%96%e6%95%b0%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/SmokeyDays.top\/wordpress\/2019\/01\/28\/lp2774-%e6%96%b9%e6%a0%bc%e5%8f%96%e6%95%b0%e9%97%ae%e9%a2%98\/","title":{"rendered":"lp2774 \u65b9\u683c\u53d6\u6570\u95ee\u9898"},"content":{"rendered":"\n<p>\u8fd9\u662f\u4e00\u9053\u6700\u5c0f\u5272\u8f6c\u6700\u5927\u6d41\u7684\u4f8b\u9898\u3002<br>\n\u9996\u5148\uff0c\u6211\u4eec\u53d1\u73b0\uff0c\u8fd9\u4e00\u9898\u8981\u6c42\u6211\u4eec\u6c42\u7684\u662f\u6240\u53d6\u548c\u3002\u7136\u540e\u5bb9\u6613\u77e5\u9053\uff0c\u6240\u53d6\u548c\u7b49\u4e8e\u603b\u548c\u51cf\u53bb\u820d\u5f03\u548c\u3002<br>\n\u6545\u800c\uff0c\u6211\u4eec\u8981\u4f7f\u5f97\u6240\u53d6\u548c\u6700\u5927\uff0c\u5c31\u53ea\u9700\u8981\u4f7f\u5f97\u820d\u5f03\u548c\u6700\u5c0f\u3002<br>\n\u5c1d\u8bd5\u7528\u6240\u53d6\u548c\u6765\u5efa\u56fe\u5e76\u4e14\u8dd1\u6700\u5927\u6d41\uff0c\u53d1\u73b0\uff0c\u5b83\u5e76\u4e0d\u662f\u90a3\u4e48\u5bb9\u6613\u5730\u5efa\u6210\u4e00\u4e2a\u53ef\u9760\u7684\u56fe\u3002<br>\n\u6b63\u96be\u5219\u53cd\uff0c\u6211\u4eec\u8003\u8651\u600e\u4e48\u6837\u624d\u80fd\u8ba9\u820d\u5f03\u548c\u6700\u5c0f\u3002<br>\n\u4e8e\u662f\u5c1d\u8bd5\u7528\u820d\u5f03\u548c\u6700\u5c0f\u6765\u5efa\u56fe\u5e76\u4e14\u8dd1\u6700\u5c0f\u5272\u3002\u89c2\u5bdf\u9898\u76ee\u7684\u6027\u8d28\u6211\u4eec\u53d1\u73b0\uff0c\u6240\u6709\u7684\u5750\u6807\u548c\u7684\u5947\u5076\u6027\u76f8\u540c\u7684\u65b9\u683c\uff0c\u6c38\u8fdc\u662f\u4e92\u4e0d\u5f71\u54cd\u7684\u3002<br>\n\u8fd9\u542f\u53d1\u6211\u4eec\u5efa\u4e00\u4e2a\u4e8c\u5206\u56fe\u3002 <br>\n\u6211\u4eec\u4e0d\u59a8\u5c06\u5947\u70b9\u5efa\u5728\u5de6\u4fa7\uff0c\u5076\u70b9\u5efa\u5728\u53f3\u4fa7\u3002\u7136\u540e\u4ece\u6e90\u70b9\u5411\u5947\u70b9\u8fde\u5bb9\u91cf\u4e3a\u6570\u503c\u7684\u8fb9\uff1b\u4ece\u5076\u70b9\u5411\u6c47\u70b9\u8fde\u5bb9\u91cf\u4e3a\u6570\u503c\u7684\u8fb9\u3002<br>\n\u4e8e\u662f\uff0c\u5f88\u663e\u7136\uff0c\u5f53\u6211\u4eec\u5272\u6389\u4efb\u4f55\u4e00\u6761\u8fb9\u7684\u65f6\u5019\uff0c\u5c31\u610f\u5473\u7740\u76f8\u5e94\u7684\u70b9\u662f\u4e0d\u53d6\u7684\u3002<br>\n\u63a5\u7740\u6211\u4eec\u5c06\u76f8\u90bb\u7684\u9ed1\u767d\u70b9\u8fde\u5bb9\u91cf\u4e3a\u65e0\u7a77\u5927\u7684\u8fb9\uff0c\u8fd9\u610f\u5473\u7740\u8fd9\u4e24\u4e2a\u70b9\u4e4b\u95f4\u81f3\u5c11\u6709\u4e00\u4e2a\u4e0d\u80fd\u53d6\u3002<br>\n\u7136\u540e\u8dd1\u6700\u5927\u6d41\u5f97\u5230\u6700\u5c0f\u5272\u5373\u53ef\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream>\n#include&lt;cstdio>\n#include&lt;queue>\n\n\nconst int INF=2147483647;\nconst int VERYBIG=0x3f3f3f3f; \n\ninline int Min(int A,int B){\n\treturn A&lt;B?A:B;\n}\n\n\nstruct ee{\n\tint v;\n\tint w;\n\tint nxt;\n}e[200005];\nint h[40005],et=-1;\nint dep[40005],nw[40005];\n\ninline void Eadd(int U,int V,int W){\n\te[++et]=(ee){V,W,h[U]};\n\th[U]=et;\n}\n\ninline void add(int U,int V,int W){\n\tEadd(U,V,W);\n\tEadd(V,U,0);\n}\n\nint n,m,s,t;\n\ninline int calc(int X,int Y){\n\treturn (X-1)*m+Y;\n}\n\nstd::queue&lt;int> q;\ninline bool bfs(){\n\tfor(int i=1;i&lt;=t;++i){\n\t\tdep[i]=INF;\n\t\tnw[i]=h[i];\n\t}\n\twhile(!q.empty()){\n\t\tq.pop();\n\t}\n\tdep[s]=0;\n\tq.push(s);\n\tint p;\n\twhile(!q.empty()){\n\t\tp=q.front();\n\t\tq.pop();\n\t\tfor(int i=h[p];i>=0;i=e[i].nxt){\n\t\t\tif(dep[e[i].v]==INF&amp;&amp;e[i].w){\n\t\t\t\tdep[e[i].v]=dep[p]+1;\n\t\t\t\tq.push(e[i].v);\n\t\t\t}\n\t\t}\n\t}\n\treturn dep[t]&lt;INF;\n}\n\ninline int dfs(int X,int V){\n\tif(!V||X==t){\n\t\treturn V;\n\t}\n\tint cnt=0,val;\n\tfor(int i=nw[X];i>=0;i=e[i].nxt){\n\t\tnw[X]=i;\n\t\tif(dep[e[i].v]==dep[X]+1){\n\t\t\tval=dfs(e[i].v,Min(e[i].w,V));\n\t\t\tif(val){\n\t\t\t\tV-=val;\n\t\t\t\tcnt+=val;\n\t\t\t\te[i].w-=val;\n\t\t\t\te[i^1].w+=val;\n\t\t\t\tif(!V){\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\treturn cnt;\n}\n\ninline int dinic(){\n\tint ans=0;\n\twhile(bfs()){\n\t\tans+=dfs(s,INF);\n\t}\n\treturn ans;\n}\n\nvoid init(){\n\tscanf(\"%d%d\",&amp;n,&amp;m);\n\ts=n*m+1,t=n*m+2;\n\tfor(int i=1;i&lt;=t;++i){\n\t\th[i]=-1;\n\t}\n\tint x,cnt=0;\n\tfor(int i=1;i&lt;=n;++i){\n\t\tfor(int j=1;j&lt;=m;++j){\n\t\t\tscanf(\"%d\",&amp;x);\n\t\t\tcnt+=x;\n\t\t\tif((i+j)&amp;1){\n\t\t\t\tadd(s,calc(i,j),x);\n\t\t\t\tif(i+1&lt;=n){\n\t\t\t\t\tadd(calc(i,j),calc(i+1,j),VERYBIG);\n\t\t\t\t}\n\t\t\t\tif(i-1>=1){\n\t\t\t\t\tadd(calc(i,j),calc(i-1,j),VERYBIG);\n\t\t\t\t}\n\t\t\t\tif(j+1&lt;=m){\n\t\t\t\t\tadd(calc(i,j),calc(i,j+1),VERYBIG);\n\t\t\t\t}\n\t\t\t\tif(j-1>=1){\n\t\t\t\t\tadd(calc(i,j),calc(i,j-1),VERYBIG);\t\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tadd(calc(i,j),t,x);\n\t\t\t} \n\t\t}\n\t}\n\tprintf(\"%d\\n\",cnt-dinic());\n}\n\nint main(){\n\tinit();\n\treturn 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u662f\u4e00\u9053\u6700\u5c0f\u5272\u8f6c\u6700\u5927\u6d41\u7684\u4f8b\u9898\u3002 \u9996\u5148\uff0c\u6211\u4eec\u53d1\u73b0\uff0c\u8fd9\u4e00\u9898\u8981\u6c42\u6211\u4eec\u6c42\u7684\u662f\u6240\u53d6\u548c\u3002\u7136\u540e\u5bb9\u6613\u77e5\u9053\uff0c\u6240\u53d6\u548c\u7b49\u4e8e\u603b\u548c\u51cf\u53bb\u820d &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/SmokeyDays.top\/wordpress\/2019\/01\/28\/lp2774-%e6%96%b9%e6%a0%bc%e5%8f%96%e6%95%b0%e9%97%ae%e9%a2%98\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201clp2774 \u65b9\u683c\u53d6\u6570\u95ee\u9898\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":[30,77,6,75,78,5],"tags":[],"_links":{"self":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/573"}],"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=573"}],"version-history":[{"count":1,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/573\/revisions"}],"predecessor-version":[{"id":574,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/573\/revisions\/574"}],"wp:attachment":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/media?parent=573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/categories?post=573"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/tags?post=573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}