#include<bits/stdc++.h>
using namespace std;
const int N=1000;//故意整人,题目数据范围不可信
int n,m,s,d;
int w[N],g[N][N],dist[N],cnt[N],num[N],path[N];
bool st[N];
stack<int> sk;
void dij()
{
st[s]=true;
dist[s]=0;
cnt[s]=1;
num[s]=w[s];
for( int i=0;i<n;i++ )
{
int t=-1;
for( int j=0;j<n;j++ )
{
if( !st[j] && (t==-1 || dist[t]>dist[j]) ) t=j;
}
st[t]=true;
for( int j=0 ;j<n;j++ )
{
if( dist[t]+g[t][j] < dist[j] )
{
dist[j] = dist[t]+g[t][j];
cnt[j] = cnt[t];
num[j] = num[t]+ w[j];
path[j]=t;
}
else if( dist[t]+g[t][j] == dist[j])
{
cnt[j] = cnt[j]+cnt[t];
if( num[j]<num[t]+w[j] )
{
num[j] = num[t] +w[j];
path[j]=t;
}
}
}
}
}
int main()
{
cin>>n>>m>>s>>d;
for( int i=0;i<n;i++) cin>>w[i];
memset(g,0x3f,sizeof(g));
while( m-- )
{
int a,b,c;
cin>>a>>b>>c;
g[a][b]=g[b][a]=c;
}
memset(dist,0x3f,sizeof(dist));
for( int i=0;i<n;i++ )
{
dist[i]=g[s][i];
if( g[s][i]!=0x3f3f3f3f )
{
path[i]=s;
num[i]=w[i]+w[s];
cnt[i]=1;
}
else
{
path[i]=-1;
num[i]=w[i];
cnt[i]=0;
}
}
dij();
cout<<cnt[d]<<" "<<num[d]<<"\n";
cout<<s;
while( s!=d )
{
sk.push(d);
d=path[d];
}
while( sk.size()!=0 )
{
cout<<" "<<sk.top();
sk.pop();
}
return 0;
}
08-27
470
09-07
386
09-16
1108
08-04
657