#include #include #include #define INF 1000000000 #define N 1005 using namespace std; int list[N],dis[N],hx[N],hy[N],px[N],py[N],tot,pre[N],pr[N]; char map[205][205]; struct dian { int date,value,next,cost; }cun[2000005]; void add(int a,int b,int c,int d) { cun[++tot].date=b; cun[tot].value=c; cun[tot].next=list[a]; cun[tot].cost=d; list[a]=tot; cun[++tot].date=a; cun[tot].value=0; cun[tot].next=list[b]; cun[tot].cost=-d; list[b]=tot; } int abss(int a) { if(a>0) return a; return -a; } int spfa(int s,int t) { queue p; int vis[N]; for(int i=0;i<1005;i++) { dis[i]=INF; vis[i]=0; pre[i]=-1; } dis[s]=0; p.push(s); int k; while(!p.empty()) { k=p.front(); p.pop(); vis[k]=0; for(int i=list[k];i;i=cun[i].next) { int w=cun[i].value; int c=cun[i].cost; int to=cun[i].date; if(w>0&&dis[to]>dis[k]+c) { dis[to]=dis[k]+c; pre[to]=k; pr[to]=i; if(!vis[to]) { vis[to]=1; p.push(to); } } } } if(dis[t]>=INF) return 0; return 1; } int maxflow(int s,int t) { int min=INF; int sum=0; while(spfa(s,t)) { for(int i=t;i!=s;i=pre[i]) { if(min