#include <iostream>
#include <sstream>
#include <string>
#include <sstream>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#define maxm 1010
#define inf 0x3fffffff
using namespace std;
int G[maxm][maxm];
int cost[maxm][maxm];
int dist[maxm]={0};
bool vis[maxm]={false};
int mcost[maxm]={0};
int path[maxm];
void DFS(int o,int s){
if(o==s){
printf("%d ",s);
return;
}
int t=path[o];
DFS(t,s);
printf("%d ",o);
}
int main()
{
fill(G[0],G[0]+maxm*maxm,inf);
fill(cost[0],cost[0]+maxm*maxm,inf);
fill(dist,dist+maxm,inf);
fill(mcost,mcost+maxm,inf); //error mcost not cost
int n,m,s,o;
cin>>n>>m>>s>>o;
int a,b,d,c;
dist[s]=0; //s not 0
mcost[s]=0; //error mcost not cost
for(int i=0;i<n;i++)path[i]=i;
for(int i=0; i<m; i++)
{
scanf("%d%d%d%d",&a,&b,&d,&c);
G[a][b]=G[b][a]=d; //G[b][a]==d?
cost[a][b]=cost[b][a]=c;
}
for(int x=0; x<n; x++) //dont't left it
{
int v=-1,mw=inf;
for(int i=0; i<n; i++)
{
if(vis[i]==false&&dist[i]<mw)
{
mw=dist[i];
v=i;
}
}
if(v==-1)break;
vis[v]=true;
for(int i=0; i<n; i++)
{
if(vis[i]==false&&G[v][i]!=inf)
{
if(dist[i]>dist[v]+G[v][i])
{
dist[i]=dist[v]+G[v][i];
mcost[i]=mcost[v]+cost[v][i];
path[i]=v;
}
else if(dist[i]==dist[v]+G[v][i]&&mcost[i]>mcost[v]+cost[i][v])
{
mcost[i]=mcost[v]+cost[i][v];
path[i]=v;
}
}
}
}
DFS(o,s);
cout<<dist[o]<<" "<<mcost[o]; //mcost not cost
return 0;
}
总结:低级错误很多,看看错误