{"id":206,"date":"2010-04-03T13:51:00","date_gmt":"2010-04-03T05:51:00","guid":{"rendered":"http:\/\/localhost\/?p=206"},"modified":"2010-04-03T13:51:00","modified_gmt":"2010-04-03T05:51:00","slug":"scoi2007_lizard","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=206","title":{"rendered":"[SCOI2007]\u8725\u8734"},"content":{"rendered":"<p> SCOI2007]\u8725\u8734<\/p>\n<p>Time Limit:1000MS&#160; Memory Limit:165536K<br \/>Total Submit:44 Accepted:29<\/p>\n<p><strong>Description <\/strong><\/p>\n<p> \u5728\u4e00\u4e2ar\u884cc\u5217\u7684\u7f51\u683c\u5730\u56fe\u4e2d\u6709\u4e00\u4e9b\u9ad8\u5ea6\u4e0d\u540c\u7684\u77f3\u67f1\uff0c\u4e00\u4e9b\u77f3\u67f1\u4e0a\u7ad9\u7740\u4e00\u4e9b\u8725\u8734\uff0c\u4f60\u7684\u4efb\u52a1\u662f\u8ba9\u5c3d\u91cf\u591a\u7684\u8725\u8734\u9003\u5230\u8fb9\u754c\u5916\u3002  <br \/>\u6bcf\u884c\u6bcf\u5217\u4e2d\u76f8\u90bb\u77f3\u67f1\u7684\u8ddd\u79bb\u4e3a1\uff0c\u8725\u8734\u7684\u8df3\u8dc3\u8ddd\u79bb\u662fd\uff0c\u5373\u8725\u8734\u53ef\u4ee5\u8df3\u5230\u5e73\u9762\u8ddd\u79bb\u4e0d\u8d85\u8fc7d\u7684\u4efb\u4f55\u4e00\u4e2a\u77f3\u67f1\u4e0a\u3002\u77f3\u67f1\u90fd\u4e0d\u7a33\u5b9a\uff0c\u6bcf\u6b21\u5f53\u8725\u8734\u8df3\u8dc3\u65f6\uff0c\u6240\u79bb\u5f00 \u7684\u77f3\u67f1\u9ad8\u5ea6\u51cf1\uff08\u5982\u679c\u4ecd\u7136\u843d\u5728\u5730\u56fe\u5185\u90e8\uff0c\u5219\u5230\u8fbe\u7684\u77f3\u67f1\u9ad8\u5ea6\u4e0d\u53d8\uff09\uff0c\u5982\u679c\u8be5\u77f3\u67f1\u539f\u6765\u9ad8\u5ea6\u4e3a1\uff0c\u5219\u8725\u8734\u79bb\u5f00\u540e\u6d88\u5931\u3002\u4ee5\u540e\u5176\u4ed6\u8725\u8734\u4e0d\u80fd\u843d\u811a\u3002\u4efb\u4f55\u65f6\u523b\u4e0d\u80fd\u6709\u4e24\u53ea \u8725\u8734\u5728\u540c\u4e00\u4e2a\u77f3\u67f1\u4e0a\u3002  <\/p>\n<p><strong>Input <\/strong><\/p>\n<p> \u8f93\u5165\u7b2c\u4e00\u884c\u4e3a\u4e09\u4e2a\u6574\u6570r\uff0cc\uff0cd\uff0c\u5373\u5730\u56fe\u7684\u89c4\u6a21\u4e0e\u6700\u5927\u8df3\u8dc3\u8ddd\u79bb\u3002\u4ee5\u4e0br\u884c\u4e3a\u77f3\u7af9\u7684\u521d\u59cb\u72b6\u6001\uff0c0\u8868\u793a\u6ca1\u6709\u77f3\u67f1\uff0c1~3\u8868\u793a\u77f3\u67f1\u7684\u521d\u59cb\u9ad8\u5ea6\u3002\u4ee5\u4e0br\u884c\u4e3a\u8725\u8734\u4f4d \u7f6e\uff0c\u201cL\u201d\u8868\u793a\u8725\u8734\uff0c\u201c.\u201d\u8868\u793a\u6ca1\u6709\u8725\u8734\u3002  <\/p>\n<p><strong>Output <\/strong><\/p>\n<p> \u8f93\u51fa\u4ec5\u4e00\u884c\uff0c\u5305\u542b\u4e00\u4e2a\u6574\u6570\uff0c\u5373\u65e0\u6cd5\u9003\u79bb\u7684\u8725\u8734\u603b\u6570\u7684\u6700\u5c0f\u503c\u3002  <\/p>\n<p><strong>Sample Input <\/strong><\/p>\n<p>5 8 2<br \/>00000000<br \/>02000000<br \/>00321100<br \/>02000000<br \/>00000000<br \/>&#8230;&#8230;..<br \/>&#8230;&#8230;..<br \/>..LLLL..<br \/>&#8230;&#8230;..<br \/>&#8230;&#8230;..<\/p>\n<p><strong>Sample Output <\/strong><\/p>\n<p>1<\/p>\n<p><strong>Hint <\/strong><\/p>\n<p> 100%\u7684\u6570\u636e\u6ee1\u8db3\uff1a1&lt;=r, c&lt;=20, 1&lt;=d&lt;=3 <\/p>\n<p><strong>Source <\/strong><\/p>\n<p> Pku 2711 Leapin&#8217; Lizards<br \/>\u6709\u70b9\u6c34\u7684\u7f51\u7edc\u6d41\uff0c\u76f4\u63a5\u62c6\u70b9\u6784\u56fe\u5c31\u53ef\u4ee5\u4e86\u3002\u3002<br \/>Code\uff1a<\/p>\n<p>#include&lt;cstdio&gt;<br \/>#include&lt;iostream&gt;<br \/>#include&lt;algorithm&gt;<br \/>#include&lt;string&gt;<br \/>#include&lt;vector&gt;<br \/>#include&lt;cstring&gt;<br \/>#include&lt;cmath&gt;<br \/>#define rep(i,n) for(int i=0;i&lt;n;i++)<br \/>#define pb push_back<br \/>using namespace std;<br \/>typedef pair&lt;int,int&gt; ii;<br \/>const int inf=~0U&gt;&gt;1,maxn=20,maxv=maxn*maxn*2+2;<br \/>int n,m;<br \/>inline int In(int i,int j){return (i*m+j)*2;}<br \/>inline int Out(int i,int j){return In(i,j)+1;}<br \/>struct Edge<br \/>{<br \/>    int t,c;<br \/>    Edge*next,*op;<br \/>    Edge(int _t,int _c,Edge*_next):t(_t),c(_c),next(_next){}<br \/>}*E[maxv]={0};<br \/>int h[maxv],vh[maxv],vs,vt,v;<br \/>void InsEdge(int s,int t,int c)<br \/>{<br \/>    E[s]=new Edge(t,c,E[s]);<br \/>    E[t]=new Edge(s,0,E[t]);<br \/>    E[s]-&gt;op=E[t];E[t]-&gt;op=E[s];<br \/>}<br \/>int aug(int no,int m)<br \/>{<br \/>    if(no==vt) return m;<br \/>    int l=m;<br \/>    for(Edge*i=E[no];i;i=i-&gt;next)if(i-&gt;c&amp;&amp;h[no]==h[i-&gt;t]+1)<br \/>    {<br \/>        int d=aug(i-&gt;t,min(i-&gt;c,l));<br \/>        l-=d,i-&gt;c-=d,i-&gt;op-&gt;c+=d;<br \/>        if(l==0||h[vs]&gt;=v)return m-l;<br \/>    }<br \/>    int minh=v;<br \/>    for(Edge*i=E[no];i;i=i-&gt;next)if(i-&gt;c&amp;&amp;h[i-&gt;t]+1&lt;minh)<br \/>        minh=h[i-&gt;t]+1;<br \/>    if(&#8211;vh[h[no]]==0) h[vs]=v;vh[h[no]=minh]++;<br \/>    return m-l;<br \/>}<br \/>int CalFlow()<br \/>{<br \/>    memset(h,0,sizeof(h));<br \/>    memset(vh,0,sizeof(vh));<br \/>    vh[0]=v;<br \/>    int flow=0;while(h[vs]&lt;v)flow+=aug(vs,inf);<br \/>    return flow;<br \/>}<br \/>inline int Dist(ii a,ii b){return abs(a.first-b.first)+abs(a.second-b.second);}<br \/>inline int DistToExit(int x,int y){return min(x+1,min(n-x,min(y+1,m-y)));}<br \/>int main()<br \/>{<br \/>    \/\/freopen(&quot;in&quot;,&quot;r&quot;,stdin);<br \/>    int x,d,a=0;char c;cin&gt;&gt;n&gt;&gt;m&gt;&gt;d;v=n*m*2+2;vs=v-1;vt=vs-1;<br \/>    rep(i,n)rep(j,m){cin&gt;&gt;c;x=c-&#8216;0&#8217;;if(x)InsEdge(In(i,j),Out(i,j),x);}<br \/>    rep(i,n)rep(j,m){cin&gt;&gt;c;if(c==&#8217;L&#8217;) InsEdge(vs,In(i,j),1),a++;}<br \/>    rep(i,n)rep(j,m)rep(a,n)rep(b,m)if(Dist(ii(i,j),ii(a,b))&lt;=d) InsEdge(Out(i,j),In(a,b),inf);<br \/>    rep(i,n)rep(j,m)if(DistToExit(i,j)&lt;=d) InsEdge(Out(i,j),vt,inf);<br \/>    cout&lt;&lt;a-CalFlow()&lt;&lt;endl;<br \/>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SCOI2007]\u8725\u8734 Time Limit:1000MS&#160; Memory Limit:165536KTotal Submit:44 Accepted:29 Description \u5728\u4e00\u4e2ar\u884cc\u5217\u7684\u7f51\u683c\u5730\u56fe\u4e2d\u6709\u4e00\u4e9b\u9ad8\u5ea6\u4e0d\u540c\u7684\u77f3\u67f1\uff0c\u4e00\u4e9b\u77f3\u67f1\u4e0a\u7ad9\u7740\u4e00\u4e9b\u8725\u8734\uff0c\u4f60\u7684\u4efb\u52a1\u662f\u8ba9\u5c3d\u91cf\u591a\u7684\u8725\u8734\u9003\u5230\u8fb9\u754c\u5916\u3002 \u6bcf\u884c\u6bcf\u5217\u4e2d\u76f8\u90bb\u77f3\u67f1\u7684\u8ddd\u79bb\u4e3a1\uff0c\u8725\u8734\u7684\u8df3\u8dc3\u8ddd\u79bb\u662fd\uff0c\u5373\u8725\u8734\u53ef\u4ee5\u8df3\u5230\u5e73\u9762\u8ddd\u79bb\u4e0d\u8d85\u8fc7d\u7684\u4efb\u4f55\u4e00\u4e2a\u77f3\u67f1\u4e0a\u3002\u77f3\u67f1\u90fd\u4e0d\u7a33\u5b9a\uff0c\u6bcf\u6b21\u5f53\u8725\u8734\u8df3\u8dc3\u65f6\uff0c\u6240\u79bb\u5f00 \u7684\u77f3\u67f1\u9ad8\u5ea6\u51cf1\uff08\u5982\u679c\u4ecd\u7136\u843d\u5728\u5730\u56fe\u5185\u90e8\uff0c\u5219\u5230\u8fbe\u7684\u77f3\u67f1\u9ad8\u5ea6\u4e0d\u53d8\uff09\uff0c\u5982\u679c\u8be5\u77f3\u67f1\u539f\u6765\u9ad8\u5ea6\u4e3a1\uff0c\u5219\u8725\u8734\u79bb\u5f00\u540e\u6d88\u5931\u3002\u4ee5\u540e\u5176\u4ed6\u8725\u8734\u4e0d\u80fd\u843d\u811a\u3002\u4efb\u4f55\u65f6\u523b\u4e0d\u80fd\u6709\u4e24\u53ea \u8725\u8734\u5728\u540c\u4e00\u4e2a\u77f3\u67f1\u4e0a\u3002 Input \u8f93\u5165\u7b2c\u4e00\u884c\u4e3a\u4e09\u4e2a\u6574\u6570r\uff0cc\uff0cd\uff0c\u5373\u5730\u56fe\u7684\u89c4\u6a21\u4e0e\u6700\u5927\u8df3\u8dc3\u8ddd\u79bb\u3002\u4ee5\u4e0br\u884c\u4e3a\u77f3\u7af9\u7684\u521d\u59cb\u72b6\u6001\uff0c0\u8868\u793a\u6ca1\u6709\u77f3\u67f1\uff0c1~3\u8868\u793a\u77f3\u67f1\u7684\u521d\u59cb\u9ad8\u5ea6\u3002\u4ee5\u4e0br\u884c\u4e3a\u8725\u8734\u4f4d \u7f6e\uff0c\u201cL\u201d\u8868\u793a\u8725\u8734\uff0c\u201c.\u201d\u8868\u793a\u6ca1\u6709\u8725\u8734\u3002 Output \u8f93\u51fa\u4ec5\u4e00\u884c\uff0c\u5305\u542b\u4e00\u4e2a\u6574\u6570\uff0c\u5373\u65e0\u6cd5\u9003\u79bb\u7684\u8725\u8734\u603b\u6570\u7684\u6700\u5c0f\u503c\u3002 Sample Input 5 8 20000000002000000003211000200000000000000&#8230;&#8230;..&#8230;&#8230;&#8230;.LLLL..&#8230;&#8230;..&#8230;&#8230;.. Sample Output 1 Hint 100%\u7684\u6570\u636e\u6ee1\u8db3\uff1a1&lt;=r, c&lt;=20, 1&lt;=d&lt;=3 Source Pku 2711 Leapin&#8217; Lizards\u6709\u70b9\u6c34\u7684\u7f51\u7edc\u6d41\uff0c\u76f4\u63a5\u62c6\u70b9\u6784\u56fe\u5c31\u53ef\u4ee5\u4e86\u3002\u3002Code\uff1a #include&lt;cstdio&gt;#include&lt;iostream&gt;#include&lt;algorithm&gt;#include&lt;string&gt;#include&lt;vector&gt;#include&lt;cstring&gt;#include&lt;cmath&gt;#define rep(i,n) for(int i=0;i&lt;n;i++)#define pb push_backusing namespace std;typedef pair&lt;int,int&gt; ii;const int inf=~0U&gt;&gt;1,maxn=20,maxv=maxn*maxn*2+2;int n,m;inline int In(int i,int j){return (i*m+j)*2;}inline int Out(int i,int [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/206"}],"collection":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=206"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/206\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}