//路径numr 若找到一条更短的,则numr替换,人数累加,
若相等,则当前路径+=之前路径,找寻最大的人数
但是 有一个例子过不去
#include<iostream>
#include<cstring>
#include<queue>
#include<vector>
using namespace std;
const int Max=500+5;
const int inf=0x3f3f3f3f;
int nump[Max], ans[Max], dis[Max], numr[Max];
int vis[Max], first[Max], num;
typedef pair<int, int> P;
struct EDGE {
int v, d, next;
} edge[Max*2]; //链式向前星
void init() {
fill(ans, ans+Max, 0); //memset只能初始化-1,0,1
memset(first,-1,sizeof(first));
memset(vis, 0, sizeof(vis));
fill(dis, dis+Max, inf);
num = 0;
}
void addedge(int u,int v, int w) {
edge[num].v=v;
edge[num].d = w;
edge[num].next=first[u];
first[u]=num++;
// cout << u << ":" << first[u] << endl;
}
void dijkstra(int s, int e) {
priority_queue<P, vector<P>, greater<P> >q;
q.push(P(s, 0));//位置,路径长度
numr[s] = 1;
ans[s] = nump[s];
dis[s] = 0;
P tmp;
while(!q.empty()) {
tmp = q.top();
q.pop();
int u = tmp.first;
if(vis[u]) continue;
vis[u] = 1;
for(int i=first[u]; i!=-1; i=edge[i].next){
int v = edge[i].v;
int tmpd = edge[i].d;
if(dis[v] > dis[u]+tmpd) {
numr[v] = numr[u];
dis[v] = dis[u]+tmpd;
ans[v] = ans[u]+nump[v];
if(!vis[v])
q.push(P(v, dis[v]));
}else if(dis[v] == dis[u]+tmpd) {
numr[v] += numr[u];
ans[v] = max(ans[v], ans[u]+nump[v]);
if(!vis[v]){
q.push(P(v, dis[v]));
}
}
}
}
cout << numr[e] << " " << ans[e] << endl;
}
int main() {
int N, M, C1, C2;
init();
cin >> N >> M >> C1 >> C2;
for(int i=0; i<N; i++) {
cin >> nump[i];
}
for(int i=0; i<M; i++) {
int a, b, d;
cin >> a >> b >> d;
addedge(a, b, d);
addedge(b, a, d);
}
dijkstra(C1, C2);
return 0;
}