A9487 | Jzzhu and Cities
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Jzzhu is the president of country A. There are $n$ cities numbered from $1$ to $n$ in his country. City $1$ is the capital of A. Also there are $m$ roads connecting the cities. One can go from city $u_{i}$ to $v_{i}$ (and vise versa) using the $i$ -th road, the length of this road is $x_{i}$ . Finally, there are $k$ train routes in the country. One can use the $i$ -th train route to go from capital of the country to city $s_{i}$ (and vise versa), the length of this route is $y_{i}$ .
Jzzhu doesn't want to waste the money of the country, so he is going to close some of the train routes. Please tell Jzzhu the maximum number of the train routes which can be closed under the following condition: the length of the shortest path from every city to the capital mustn't change.
Jzzhu doesn't want to waste the money of the country, so he is going to close some of the train routes. Please tell Jzzhu the maximum number of the train routes which can be closed under the following condition: the length of the shortest path from every city to the capital mustn't change.
输入格式
The first line contains three integers $n,m,k$ $(2<=n<=10^{5}; 1<=m<=3·10^{5}; 1<=k<=10^{5})$ .
Each of the next $m$ lines contains three integers $u_{i},v_{i},x_{i}$ $(1<=u_{i},v_{i}<=n; u_{i}≠v_{i}; 1<=x_{i}<=10^{9})$ .
Each of the next $k$ lines contains two integers $s_{i}$ and $y_{i}$ $(2<=s_{i}<=n; 1<=y_{i}<=10^{9})$ .
It is guaranteed that there is at least one way from every city to the capital. Note, that there can be multiple roads between two cities. Also, there can be multiple routes going to the same city from the capital.
Each of the next $m$ lines contains three integers $u_{i},v_{i},x_{i}$ $(1<=u_{i},v_{i}<=n; u_{i}≠v_{i}; 1<=x_{i}<=10^{9})$ .
Each of the next $k$ lines contains two integers $s_{i}$ and $y_{i}$ $(2<=s_{i}<=n; 1<=y_{i}<=10^{9})$ .
It is guaranteed that there is at least one way from every city to the capital. Note, that there can be multiple roads between two cities. Also, there can be multiple routes going to the same city from the capital.
输出格式
Output a single integer representing the maximum number of the train routes which can be closed.
输入输出样例
输入 #1
5 5 3 1 2 1 2 3 2 1 3 3 3 4 4 1 5 5 3 5 4 5 5 5
输出 #1
2
输入 #2
2 2 3 1 2 2 2 1 3 2 1 2 2 2 3
输出 #2
2
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted