A12633 | Indecisive Taxi Fee
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
In the city of Capypaland where Kuro and Shiro resides, there are $n$ towns numbered from $1$ to $n$ and there are $m$ bidirectional roads numbered from $1$ to $m$ connecting them. The $i$ -th road connects towns $u_i$ and $v_i$ . Since traveling between the towns is quite difficult, the taxi industry is really popular here. To survive the harsh competition, each taxi company has to find a distinctive trait for their customers.
Kuro is the owner of a taxi company. He has decided to introduce a new fee model for his taxi brand, where the fee for each ride is not calculated based on the trip length, but on the sum of the prices of the roads traveled. The price for each of the $m$ roads has been decided by Kuro himself.
As of now, the price for the road $i$ is $w_i$ and hence the fee for a taxi ride traveling through roads $e_1, e_2, \ldots, e_k$ is $\sum_{i=1}^k w_{e_i}$ .
However, Kuro himself is an indecisive person, so he has drafted $q$ plans to change the road price. Each of the plans will be based on the original prices $w_i$ , except for a single road $t_j$ , the price of which is changed to $x_j$ . Note, that the plans are independent of each other.
Shiro is a regular customer of the Kuro's taxi brand since she uses the taxi to travel from town $1$ to town $n$ every day. Since she's so a regular customer, Kuro decided to show her all his $q$ plans before publishing them to the public. Now, Shiro wants to know the lowest fee she must pay to travel from the town $1$ to the town $n$ for each Kuro's plan.
Kuro is the owner of a taxi company. He has decided to introduce a new fee model for his taxi brand, where the fee for each ride is not calculated based on the trip length, but on the sum of the prices of the roads traveled. The price for each of the $m$ roads has been decided by Kuro himself.
As of now, the price for the road $i$ is $w_i$ and hence the fee for a taxi ride traveling through roads $e_1, e_2, \ldots, e_k$ is $\sum_{i=1}^k w_{e_i}$ .
However, Kuro himself is an indecisive person, so he has drafted $q$ plans to change the road price. Each of the plans will be based on the original prices $w_i$ , except for a single road $t_j$ , the price of which is changed to $x_j$ . Note, that the plans are independent of each other.
Shiro is a regular customer of the Kuro's taxi brand since she uses the taxi to travel from town $1$ to town $n$ every day. Since she's so a regular customer, Kuro decided to show her all his $q$ plans before publishing them to the public. Now, Shiro wants to know the lowest fee she must pay to travel from the town $1$ to the town $n$ for each Kuro's plan.
输入格式
The first line contains three integers $n$ , $m$ and $q$ ( $2 \le n \le 2 \cdot 10^5$ , $1 \le m, q \le 2 \cdot 10^5$ ) — the number of towns, the number of roads, and the number of plans that Kuro has drafted respectively.
The $i$ -th of the next $m$ contains three integers $u_i$ , $v_i$ and $w_i$ ( $1 \le u_i, v_i \le n$ , $1 \le w_i \le 10^9$ , $u_i \ne v_i$ ) — two endpoints and the original price of the $i$ -th road.
It is guaranteed, that there is at least one way to travel from town $1$ to town $n$ using these $m$ bidirectional roads.
Each of the next $q$ lines contains two integers $t_j$ and $x_j$ ( $1 \leq t_j \leq m, 1 \leq x_j \leq 10^9$ ) — the index of the road Kuro has planned to change and its new price respectively.
The $i$ -th of the next $m$ contains three integers $u_i$ , $v_i$ and $w_i$ ( $1 \le u_i, v_i \le n$ , $1 \le w_i \le 10^9$ , $u_i \ne v_i$ ) — two endpoints and the original price of the $i$ -th road.
It is guaranteed, that there is at least one way to travel from town $1$ to town $n$ using these $m$ bidirectional roads.
Each of the next $q$ lines contains two integers $t_j$ and $x_j$ ( $1 \leq t_j \leq m, 1 \leq x_j \leq 10^9$ ) — the index of the road Kuro has planned to change and its new price respectively.
输出格式
Print $q$ integers — the lowest fee Shiro must pay to get from town $1$ to town $n$ in each of those $q$ plans.
输入输出样例
输入 #1
4 5 6 1 2 2 2 4 3 1 4 7 1 3 1 3 4 5 3 4 5 1 3 8 1 4 2 1 3 1
输出 #1
4 2 5 6 3 1
输入 #2
2 4 4 1 2 2 1 2 3 1 2 4 1 2 5 2 1 3 2 4 3 1 5
输出 #2
1 2 2 3
输入 #3
2 1 1 1 2 1 1 3
输出 #3
3
In the first example, the original overview of Capypaland looks like this, where the number next to each road denotes the original prices of the roads,
The overview of the first plan,
The lowest fee Shiro must pay in this plan is $4$ , which corresponds to the path $1 \rightarrow 4$ .
The overview of the second plan,
The lowest fee Shiro must pay in this plan is $2$ , which corresponds to the path $1 \rightarrow 3 \rightarrow 4$ .
The overview of the third plan,
The lowest fee Shiro must pay in this plan is $5$ , which corresponds to the path $1 \rightarrow 2 \rightarrow 4$ .
The overview of the first plan,
The lowest fee Shiro must pay in this plan is $4$ , which corresponds to the path $1 \rightarrow 4$ .
The overview of the second plan,
The lowest fee Shiro must pay in this plan is $2$ , which corresponds to the path $1 \rightarrow 3 \rightarrow 4$ .
The overview of the third plan,
The lowest fee Shiro must pay in this plan is $5$ , which corresponds to the path $1 \rightarrow 2 \rightarrow 4$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted