CF1163F.Indecisive Taxi Fee

NOI/NOI+/CTSC

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In the city of Capypaland where Kuro and Shiro resides, there are nn towns numbered from 11 to nn and there are mm bidirectional roads numbered from 11 to mm connecting them. The ii-th road connects towns uiu_i and viv_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 mm roads has been decided by Kuro himself.

As of now, the price for the road ii is wiw_i and hence the fee for a taxi ride traveling through roads e1,e2,…,eke_1, e_2, \ldots, e_k is ∑i=1kwei\sum_{i=1}^k w_{e_i}.

However, Kuro himself is an indecisive person, so he has drafted qq plans to change the road price. Each of the plans will be based on the original prices wiw_i, except for a single road tjt_j, the price of which is changed to xjx_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 11 to town nn every day. Since she's so a regular customer, Kuro decided to show her all his qq plans before publishing them to the public. Now, Shiro wants to know the lowest fee she must pay to travel from the town 11 to the town nn for each Kuro's plan.

在库洛和史洛居住的卡皮亚兰德城中,共有 nn 座城镇,编号从 11 到 nn,以及 mm 条双向道路,编号从 11 到 mm,连接这些城镇。第 ii 条道路连接城镇 uiu_i 和 viv_i。由于城镇间通行十分困难,出租车行业在此地极为兴盛。为在激烈的竞争中生存下来,每家出租车公司都必须为其顾客提供独特的服务特色。

库洛是一家出租车公司的老板。他决定为其出租车品牌引入一种全新的计费模式:每次乘车的费用并非依据行程长度计算,而是依据所经道路的价格之和来计算。这 mm 条道路各自的价格均由库洛本人确定。

目前,第 ii 条道路的价格为 wiw_i,因此,若一次出租车行程经过道路 e1,e2,…,eke_1, e_2, \ldots, e_k,则其费用为 ∑i=1kwei\sum_{i=1}^k w_{e_i}。

然而,库洛本人性格优柔寡断,因此他拟定了 qq 个调整道路价格的方案。每个方案均基于原始价格 wiw_i,仅将其中一条道路 tjt_j 的价格修改为 xjx_j。注意:这些方案彼此相互独立。

史洛是库洛出租车品牌的常客,因为她每天都要乘坐出租车从城镇 11 前往城镇 nn。由于她如此忠实,库洛决定在向公众正式发布这些方案前,先向她展示全部 qq 个方案。现在,史洛希望知道:对于库洛提出的每一个方案,她从城镇 11 前往城镇 nn 所需支付的最低费用是多少?

输入格式

The first line contains three integers nn, mm and qq (2≤n≤2⋅1052 \le n \le 2 \cdot 10^5, 1≤m,q≤2⋅1051 \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 ii-th of the next mm contains three integers uiu_i, viv_i and wiw_i (1≤ui,vi≤n1 \le u_i, v_i \le n, 1≤wi≤1091 \le w_i \le 10^9, ui≠viu_i \ne v_i) — two endpoints and the original price of the ii-th road.

It is guaranteed, that there is at least one way to travel from town 11 to town nn using these mm bidirectional roads.

Each of the next qq lines contains two integers tjt_j and xjx_j (1≤tj≤m,1≤xj≤1091 \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.

第一行包含三个整数 nn、mm 和 qq(2≤n≤2⋅1052 \le n \le 2 \cdot 10^5,1≤m,q≤2⋅1051 \le m, q \le 2 \cdot 10^5),分别表示城镇数量、道路数量以及 Kuro 已拟定的方案数量。

接下来的 mm 行中,第 ii 行包含三个整数 uiu_i、viv_i 和 wiw_i(1≤ui,vi≤n1 \le u_i, v_i \le n,1≤wi≤1091 \le w_i \le 10^9,ui≠viu_i \ne v_i),表示第 ii 条道路的两个端点及其原始价格。

保证利用这 mm 条双向道路,至少存在一条从城镇 11 到城镇 nn 的路径。

接下来的 qq 行中,每行包含两个整数 tjt_j 和 xjx_j(1≤tj≤m1 \leq t_j \leq m,1≤xj≤1091 \leq x_j \leq 10^9),分别表示 Kuro 计划修改的道路编号及其新价格。

输出格式

Print qq integers — the lowest fee Shiro must pay to get from town 11 to town nn in each of those qq plans.

输出 qq 个整数——在上述 qq 种方案中,Shiro 从城镇 11 到达城镇 nn 所需支付的最低费用。

输入输出样例

  • 输入#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 44, which corresponds to the path 1→41 \rightarrow 4.

The overview of the second plan,

The lowest fee Shiro must pay in this plan is 22, which corresponds to the path 1→3→41 \rightarrow 3 \rightarrow 4.

The overview of the third plan,

The lowest fee Shiro must pay in this plan is 55, which corresponds to the path 1→2→41 \rightarrow 2 \rightarrow 4.

在第一个例子中,卡皮兰德(Capypaland)的原始概览如下图所示,其中每条道路旁的数字表示该道路的原始价格:

第一种方案的概览:

在此方案中,志郎(Shiro)需支付的最低费用为 44,对应路径 1→41 \rightarrow 4。

第二种方案的概览:

在此方案中,志郎需支付的最低费用为 22,对应路径 1→3→41 \rightarrow 3 \rightarrow 4。

第三种方案的概览:

在此方案中,志郎需支付的最低费用为 55,对应路径 1→2→41 \rightarrow 2 \rightarrow 4。

输入解题思路,AI测评打分。不知道怎么写?

首页