#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cstdio>
#include <cassert> using namespace std;
#define N 505 int a[N];
long long mat[N][N], cnt[N][N], han[N][N]; int main() {
int n, m, s, e;
while (4 == scanf("%d%d%d%d", &n, &m, &s, &e)) {
for (int i = ; i < n; ++i) {
scanf("%d", a + i);
}
memset(mat, -, sizeof mat);
memset(cnt, , sizeof cnt);
memset(han, , sizeof han);
while (m--) {
int x, y, z;
scanf("%d%d%d", &x, &y, &z);
assert(!cnt[x][y]);
mat[x][y] = mat[y][x] = z;
cnt[x][y]++;
cnt[y][x]++;
han[x][y] = a[y];
han[y][x] = a[x];
}
for (int i = ; i < n; ++i) {
for (int j = ; j < n; ++j) {
if (!cnt[j][i])continue;
for (int k = ; k < n; ++k) {
if (!cnt[i][k])continue;
if (!cnt[j][k] || mat[j][k] > mat[j][i] + mat[i][k]) {
mat[j][k] = mat[j][i] + mat[i][k];
cnt[j][k] = cnt[j][i] * cnt[i][k];
han[j][k] = han[j][i] + han[i][k];
} else if (mat[j][k] == mat[j][i] + mat[i][k]) {
cnt[j][k] += cnt[j][i] * cnt[i][k];
han[j][k] = max(han[j][k], han[j][i] + han[i][k]);
}
}
}
}
if (s == e) {
cout << 1 << ' ' << a[s] << endl;
} else {
cout << cnt[s][e] << ' ' << a[s] + han[s][e] << endl;
}
}
return 0;
} /*
5 6 0 2
1 2 1 5 3
0 1 1
0 2 2
0 3 1
1 2 1
2 4 1
3 4 1 */

最新文章

  1. pymol installation
  2. iOS开发--应用崩溃日志揭秘(二)
  3. Android之ListView的getItemViewType和getViewTypeCount
  4. Odoo Graph 指定默认 类型
  5. MVC3 新建项目
  6. oracle远程连接配置
  7. 一步一步搭建客服系统 (4) 客户列表 - JS($.ajax)调用WCF 遇到的各种坑
  8. 《REWORK》启示录 发出你的心声——程序员与身体
  9. Python-requests之POST Data的json问题
  10. HDU1312——Red and Black(DFS)
  11. Android 环境变量配置(Mac)
  12. 基于ATmgea8单片机设计的加热控制系统(转)
  13. JS 禁止刷新和右键
  14. Vim按Esc后光标左移问题的解决
  15. Python 项目实践一(外星人入侵小游戏)第二篇
  16. SqlSessionFactoryUtil
  17. Python学习:经典编程例题
  18. left join中where与on的区别
  19. is not in the sudoers file解决方法
  20. c#new和override

热门文章

  1. java面试题——高级篇
  2. 20189220余超 团队博客——阅读软件app
  3. html页面添加左侧滑动菜单与内容部分的滚动条
  4. python 列出当前目录下的所有文件和目录名
  5. CloseableHttpClient方式配置代理服务器访问外网
  6. 在电脑上部署网站lls 浏览器上访问
  7. Faiss的学习和入门文章
  8. 016 Vuetify框架
  9. 在RedisTemplate中使用scan代替keys指令
  10. 2019 ICPC 银川站