# 最短路【bzoj2464】: 中山市选[2009]小明的游戏

## 2464: 中山市选[2009]小明的游戏

#### Description

code：

#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>

using namespace std;

const int wx=1517*1517;

int sum=0,f=1; char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
while(ch>='0'&&ch<='9'){sum=(sum<<1)+(sum<<3)+ch-'0'; ch=getchar();}
return sum*f;
}

int dx[]={0,1,0,-1,0};
int dy[]={0,0,1,0,-1};

int dis[wx],a[1517][1517];
char c[wx];
int n,m,sx,sy,tx,ty,ans,num;

struct e{
int nxt,to,dis;
}edge[wx*2];

edge[num].to=to;
edge[num].dis=dis;
}

struct node{
int u,d;
friend bool operator < (const node& a,const node& b){
return a.d>b.d;
}
};

priority_queue<node > q;

void Dij(int s){
for(int i=1;i<=n*m;i++)dis[i]=0x3f3f3f3f,vis[i]=0;
dis[s]=0; q.push((node){s,0});
while(q.size()){
int u=q.top().u; q.pop();
int v=edge[i].to;
if(dis[v]>dis[u]+edge[i].dis){
dis[v]=dis[u]+edge[i].dis;
q.push((node){v,dis[v]});
}
}
}
}

int main(){
while(1){
if(!n&&!m)break;
memset(edge,0,sizeof edge);
num=0;
ans=0x3f3f3f3f;
for(int i=1;i<=n;i++){
scanf("%s",c+1);
for(int j=1;j<=m;j++){
a[i][j]=(c[j]=='#');
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
for(int k=1;k<=4;k++){
int ex=i+dx[k];
int ey=j+dy[k];
if(ex<1||ex>n||ey<1||ey>m)continue;