1#include <cstdio>2#include <iostream>3 #defineT 10014 #defineM 100055 #defineINF 0x7fffffff6#include <cstring>7 using namespacestd;8 intCnt=1, r,c,d,head[m],next[Ten*m],u[Ten*m],v[Ten*m],sum,f[ -][ -],d1[m],q[m],ans;9 Charch[ -];Ten intSintA1,intA2) One { A return(a1-1) *c+A2; - } - voidJiaintA1,intA2,intA3) the { -cnt++; -u[cnt]=A2; -v[cnt]=A3; +next[cnt]=HEAD[A1]; -head[a1]=CNT; + return; A } at BOOLPanintA1,intA2,intA3,intA4) - { - if(a1==a3&&a2==A4) - return 0; - if((A1-A3) * (A1-A3) + (A2-A4) * (A2-A4) >d*d) - return 0; in if(!F[A3][A4]) - return 0; to return 1; + } - BOOLBFS () the { *memset (D1,0,sizeof(int)*M); $ intH=0, t=1;Panax Notoginsengq[1]=0; -d1[0]=1; the for(;h<t;) + { Ah++; the intp=Q[h]; + for(intI=head[p];i;i=Next[i]) - if(!d1[u[i]]&&V[i]) $ { $d1[u[i]]=d1[p]+1; - if(D1[t]) - return 1; thet++; -q[t]=U[i];Wuyi } the } - return 0; Wu } - intDinic (intSintf) About { $ if(s==T) - returnF; - intrest=F; - for(intI=head[s];i&&rest;i=Next[i]) A if(v[i]&&d1[u[i]]==d1[s]+1) + { the intnow=dinic (U[i],min (rest,v[i)); - if(!Now ) $d1[u[i]]=0; thev[i]-=Now ; thev[i^1]+=Now ; therest-=Now ; the } - returnF-rest; in } the intMain () the { Aboutscanf"%d%d%d",&r,&c,&d); the for(intI=1; i<=r;i++) the { thescanf"%s", ch+1); + for(intj=1; j<=c;j++) - { the inta1=ch[j]-'0';Bayi if(A1) the { thef[i][j]=1; -Jia (S (i,j), S (i,j) +r*c,a1); -Jia (S (i,j) +r*c,s (i,j),0); the } the } the } the for(intI=1; i<=r;i++) - { thescanf"%s", ch+1); the for(intj=1; j<=c;j++) the if(ch[j]=='L')94 { theJia0, S (I,J),1); theJia (S (i,j),0,0); thesum++;98 } About } - for(intI=1; i<=d;i++)101 for(intJ=d+1; j<=r-d;j++)102 {103Jia (S (j,i) +r*c,t,inf);104Jia (T,s (j,i) +r*c,0); theJia (S (j,c-i+1) +r*c,t,inf);106Jia (T,s (j,c-i+1),0);107 }108 for(intI=1; i<=d;i++)109 for(intj=1; j<=c;j++) the {111Jia (S (i,j) +r*c,t,inf); theJia (T,s (i,j),0);113Jia (S (r-i+1, j) +r*c,t,inf); theJia (T,s (r-i+1, j),0); the } the for(intI=1; i<=r;i++)117 for(intj=1; j<=c;j++)118 if(F[i][j])119 for(intx=i-d;x<=i+d;x++) - for(inty=j-d;y<=j+d;y++)121 if(Pan (i,j,x,y))122 {123Jia (S (i,j) +r*c,s (x, y), INF);124Jia (S (x, y), S (i,j) +r*c,0); the }126 while(BFS ())127Sum-=dinic (0,0x7fffffff); -printf"%d\n", sum);129 return 0; the }131
This is an extremely disgusting web-traffic-splitting XI,XJ. Each has a pillar place xi,xj, high. ' L ' out of the s,xi,1, where can jump out of the building side, can jump each other stone pillars to build the side.
Bzoj 1066: [SCOI2007] Lizard