@[ChenSongMiao](/user/669325) 您说的是哪个函数的哪个 `if` 没进呢?
问问题之前可以说详细点的。
by Ew_Cors @ 2022-03-23 20:52:54
```
if(dis[tx][ty]>now.v+mmap[tx][ty]){
dis[tx][ty]=now.v+mmap[tx][ty];
node t;
t.x=tx;
t.y=ty;
t.v=dis[tx][ty];
mq.push(t);
}
```
by Undead @ 2022-03-23 20:58:28
@[ChenSongMiao](/user/669325) 我很好奇为什么您的dijkstra算法函数写成了djstl....
by sw2022 @ 2022-03-23 21:20:52
```
#include<bits/stdc++.h>
using namespace std;
#define oo 0x37ff7777777777
#define ll long long
ll m,n,a,b,c,maxx;
ll mapp[1010][1010],ans1[1010][1010],ans2[1010][1010],ans3[1010][1010];
ll mx[4]={1,-1,0,0},my[4]={0,0,1,-1};
struct node{
ll x,y,v;
bool operator < (const node &e2)const{
return v>e2.v;
}
}point;
void dj(ll x,ll y,ll dis[][1010]){
ll i,j,k;
priority_queue<node> mp;
point.x=x;
point.y=y;
point.v=dis[x][y];
mp.push(point);
while(!mp.empty()){
node now=mp.top();
mp.pop();
/*if(now.x==x&&now.y==y){
ans=min(ans,now.v);
continue;
}*/
for(i=0;i<4;i++){
ll tx=now.x+mx[i],ty=now.y+my[i];
if(tx<1||tx>n||ty<1||ty>m) continue;
if(dis[tx][ty]>now.v+mapp[tx][ty]){
dis[tx][ty]=now.v+mapp[tx][ty];
node t;
t.x=tx;
t.y=ty;
t.v=dis[tx][ty];
mp.push(t);
}
}
}
}
int main(){
cin>>n>>m>>a>>b>>c;
ll i,j,k;
for(i=n;i>=1;i--)
for(j=1;j<=m;j++){
cin>>mapp[i][j];
ans1[i][j]=oo;
ans2[i][j]=oo;
ans3[i][j]=oo;
}
ans1[1][b]=mapp[1][b];
dj(1,b,ans1);
ans2[1][c]=mapp[1][c];
dj(1,c,ans2);
ans3[n][a]=mapp[n][a];
dj(n,a,ans3);
maxx=oo;
int xx,yy;
for(i=n;i>=1;i--)
for(j=1;j<=m;j++)
if(ans1[i][j]+ans2[i][j]+ans3[i][j]-(mapp[i][j]*2)<maxx)maxx=ans1[i][j]+ans2[i][j]+ans3[i][j]-(mapp[i][j]*2)/*,xx=i,yy=j*/;
cout<<maxx<<endl;
//cout<<xx<<" "<<yy;
return 0;
}
```
by 永远爱循环 @ 2022-03-23 21:26:34
@[sw2022_](/user/668002)
简写罢了
by 永远爱循环 @ 2022-03-23 21:27:22
@[永远爱循环](/user/511007) 那也不会多出个l吧……
by sw2022 @ 2022-03-23 21:28:14
中文念迪杰斯特拉
by Undead @ 2022-03-23 21:33:53
```
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define oo 0x37ff777777
ll n,m,a,b,c,mmap[1010][1010],cnt,ans1[1010][1010],ans2[1010][1010],ans3[1010][1010],mmin=0x3f3f3f3f3f3f;
ll mx[4]={0,0,-1,1};
ll my[4]={1,-1,0,0};
struct node{
ll x,y,v;
bool operator < (const node &e2)const{
return v>e2.v;
}
}point;
void djstl(ll starh,ll starz,ll dis[][1010]){
priority_queue<node> mq;
ll i;
point.x=starh;
point.y=starz;
point.v=dis[starh][starz];
mq.push(point);//你没有加入队列,下面循环不执行
while(!mq.empty()){
node now=mq.top();
mq.pop();
for(i=0;i<4;i++){
int tx=now.x+mx[i];
int ty=now.y+my[i];
if(tx>n || tx<1 || ty>m || ty<1) {
continue;
}
if(dis[tx][ty]>now.v+mmap[tx][ty]){
dis[tx][ty]=now.v+mmap[tx][ty];
node t;
t.x=tx;
t.y=ty;
t.v=dis[tx][ty];
mq.push(t);
}
}
}
}
int main(){
ll i,j;
cin>>n>>m>>a>>b>>c;
for(i=n;i>=1;i--){
for(j=1;j<=m;j++){
cin>>mmap[i][j];
ans1[i][j]=oo;
ans2[i][j]=oo;
ans3[i][j]=oo;
}
}
ans1[n][a]=mmap[n][a];//你的dis起点没有值,只是一个oo;
djstl(n,a,ans1);
ans2[1][b]=mmap[1][b];//同上
djstl(1,b,ans2);
ans3[1][c]=mmap[1][c];//同上
djstl(1,c,ans3);
for(i=n;i>=1;i--){
for(j=1;j<=m;j++){
if(ans1[i][j]+ans2[i][j]+ans3[i][j]-2*mmap[i][j]<mmin){
mmin=ans1[i][j]+ans2[i][j]+ans3[i][j]-(2*mmap[i][j]);
}
}
}
cout<<mmin;
return 0;
}
```
by 永远爱循环 @ 2022-03-24 20:58:11
Thank you very much.
by Undead @ 2022-03-25 11:57:19