#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 */

Pat 1003 甲级的更多相关文章

  1. PAT(甲级)2017年秋季考试

    PAT(甲级)2017年秋季考试 D题红黑树待补21/30 大佬的代码,看着想哭,这才是艺术啊 A Cut Integer 模拟题 #include<bits/stdc++.h> usin ...

  2. PAT(甲级)2017年春季考试

    PAT(甲级)2017年春季考试 A.Raffle for Weibo Followers #include<bits/stdc++.h> using namespace std; int ...

  3. PAT 1003我要通过!

    PAT 1003 我要通过! 答案正确"是自动判题系统给出的最令人欢喜的回复.本题属于 PAT 的"答案正确"大派送 -- 只要读入的字符串满足下列条件,系统就输出&qu ...

  4. PAT 1003 我要通过!(20)(代码+思路)

    1003 我要通过!(20)(20 分)提问 "答案正确"是自动判题系统给出的最令人欢喜的回复.本题属于PAT的"答案正确"大派送 -- 只要读入的字符串满足下 ...

  5. 迪杰斯特拉算法——PAT 1003

    本文主要是将我对于我对于迪杰斯特拉算法的理解写出来,同时通过例题来希望能够加深对于算法的理解,其中有错误的地方希望大家指正. 迪杰斯特拉算法 我将这个算法理解成一个局部到整体的算法,这个方法确实越研究 ...

  6. PAT 1003. 我要通过!(20) JAVA

    参考http://blog.csdn.net/bin8632/article/details/50216297 答案正确"是自动判题系统给出的最令人欢喜的回复.本题属于PAT的"答 ...

  7. PAT 1003. 我要通过!(20)

    "答案正确"是自动判题系统给出的最令人欢喜的回复.本题属于PAT的"答案正确"大派送 -- 只要读入的字符串满足下列条件,系统就输出"答案正确&quo ...

  8. PAT 1003

    1003. Emergency (25) As an emergency rescue team leader of a city, you are given a special map of yo ...

  9. PAT 1003. Emergency (25)

    1003. Emergency (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue As an emerg ...

随机推荐

  1. 请教网友:#pragma pack(push) #pragma pack(pop)无效

    //try 一 try #pragma back(push) #pragma pack(2) struct E { char a; short b; double c; float d; char e ...

  2. 记一次Pr中视频蜜汁卡顿往复和解决方法

    目录 问题 换素材的起因 灵异素材 无端联想 解决 问题 换素材的起因 本来视频剪了一晚剪完了,导出一看,好家伙,糊到上世纪.原来素材的像素大小都没法看,这视频素材我是从别人U盘拷过来的,可他竟然是用 ...

  3. PHP strlen 对中文 的定义

    $zhStr = ‘您好,中国!’; // gbk编码下每个中文字符所占字节为2echo strlen($zhStr); // 输出:12 //utf-8编码下每个中文字符所占字节为3 echo st ...

  4. ORM之模型对象Model

    模型对象Model Odoo的模型对象在odoo模块的models.py文件中,最基础的对象是BaseModel; Odoo的模型对象有三个:AbstractModel.Model.Transient ...

  5. 阿里云配置DDoS高防

  6. C++核心技术登录实现

    void CLMSDlg::OnButtonlogin() { // TODO: Add your control notification handler code here CMainsystem ...

  7. 【Python爬虫案例学习】Python爬取天涯论坛评论

    用到的包有requests - BeautSoup 我爬的是天涯论坛的财经论坛:'http://bbs.tianya.cn/list.jsp?item=develop' 它里面的其中的一个帖子的URL ...

  8. k8s-Namespace(命名空间)

    k8s-Namespace(命名空间) Namespace(命名空间)是Kubernetes系统中的另一个非常重要的概念,通过将系统内部的对象“分配”到不同的Namespace中,形成逻辑上分组的不同 ...

  9. SQL系列(十四)—— 视图(view)

    说到视图view,大家应该都很熟悉.如几何学中用三视图来描述集合物体的外观构成,三视图中反应出物体的面貌.这里我们讨论数据库中视图的概念: 什么是视图 为什么会有会用视图 怎样使用视图 视图与表的异同 ...

  10. Google Guava Cache 全解析

    Google guava工具类的介绍和使用https://blog.csdn.net/wwwdc1012/article/details/82228458 LoadingCache缓存使用(Loadi ...