简单的图
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int map[505][505];
int teams[505];
int vis[505];
int n, m, start, endc;
int INF = 100000;
int pmin = INF, path = 0, tmax = 0;
void solve(int len, int x, int team){
if(x == endc){
if(len < pmin){
pmin = len;
path = 1;
tmax = team;
}
else if(len == pmin){
path++;
tmax = max(team, tmax);
}
return;
}
for(int i = 0; i < n; i++){
if(vis[i] == 0 && map[x][i] < INF && len + map[x][i] <= pmin){
vis[i] = 1;
solve(len + map[x][i], i, team+teams[i]);
vis[i] = 0;
}
}
}
int main(){
scanf("%d%d%d%d",&n,&m,&start,&endc);
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++)
map[i][j] = INF;
}
memset(vis, 0, n);
for(int i = 0; i < n; i++)
scanf("%d",&teams[i]);
for(int i = 0; i < m; i++){
int x, y, v;
scanf("%d%d%d",&x,&y,&v);
map[x][y] = map[y][x] = v;
}
vis[start] = 1;
solve(0, start, teams[start]);
printf("%d %d", path, tmax);
return 0;
}