CF1307G.Cow and Exercise

NOI/NOI+/CTSC

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Farmer John is obsessed with making Bessie exercise more!

Bessie is out grazing on the farm, which consists of nn fields connected by mm directed roads. Each road takes some time wiw_i to cross. She is currently at field 11 and will return to her home at field nn at the end of the day.

Farmer John has plans to increase the time it takes to cross certain roads. He can increase the time it takes to cross each road by a nonnegative amount, but the total increase cannot exceed xix_i for the ii-th plan.

Determine the maximum he can make the shortest path from 11 to nn for each of the qq independent plans.

农夫约翰痴迷于让贝茜多锻炼!

贝茜正在农场上吃草。农场由 nn 个田地组成,这些田地之间通过 mm 条有向道路相连。每条道路的通行时间为 wiw_i。她当前位于第 11 号田地,并将在一天结束时返回位于第 nn 号田地的家。

农夫约翰计划增加某些道路的通行时间。他可以将每条道路的通行时间增加一个非负的量,但对于第 ii 个计划,所有道路的总增加量不能超过 xix_i。

对于 qq 个相互独立的计划,请分别求出从 11 到 nn 的最短路径长度所能达到的最大值。

输入格式

The first line contains integers nn and mm (2≤n≤502 \le n \le 50, 1≤m≤n⋅(n−1)1 \le m \le n \cdot (n-1)) — the number of fields and number of roads, respectively.

Each of the following mm lines contains 33 integers, uiu_i, viv_i, and wiw_i (1≤ui,vi≤n1 \le u_i, v_i \le n, 1≤wi≤1061 \le w_i \le 10^6), meaning there is an road from field uiu_i to field viv_i that takes wiw_i time to cross.

It is guaranteed that there exists a way to get to field nn from field 11. It is guaranteed that the graph does not contain self-loops or parallel edges. It is possible to have a road from uu to vv and a road from vv to uu.

The next line contains a single integer qq (1≤q≤1051 \le q \le 10^5), the number of plans.

Each of the following qq lines contains a single integer xix_i, the query (0≤xi≤1050 \le x_i \le 10^5).

第一行包含两个整数 nn 和 mm(2≤n≤502 \le n \le 50,1≤m≤n⋅(n−1)1 \le m \le n \cdot (n-1)),分别表示田地的数量和道路的数量。

接下来的 mm 行中,每行包含三个整数 uiu_i、viv_i 和 wiw_i(1≤ui,vi≤n1 \le u_i, v_i \le n,1≤wi≤1061 \le w_i \le 10^6),表示存在一条从田地 uiu_i 到田地 viv_i 的道路,穿越该道路所需时间为 wiw_i。

保证存在一条从田地 11 到田地 nn 的路径。保证图中不含自环或重边。但可能存在一条从 uu 到 vv 的道路以及另一条从 vv 到 uu 的道路。

下一行包含一个整数 qq(1≤q≤1051 \le q \le 10^5),表示计划的数量。

接下来的 qq 行中,每行包含一个整数 xix_i,表示查询值(0≤xi≤1050 \le x_i \le 10^5)。

输出格式

For each query, output the maximum Farmer John can make the shortest path if the total increase does not exceed xix_i.

Your answer is considered correct if its absolute or relative error does not exceed 10−610^{-6}.

Formally, let your answer be aa, and the jury's answer be bb. Your answer is accepted if and only if ∣a−b∣max⁡(1,∣b∣)≤10−6\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}.

对于每个查询,请输出在总增加量不超过 xix_i 的前提下,农夫约翰能使最短路径达到的最大长度。

若你的答案的绝对误差或相对误差不超过 10−610^{-6},则视为正确。

形式化地,设你的答案为 aa,评测组的答案为 bb。当且仅当 ∣a−b∣max⁡(1,∣b∣)≤10−6\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6} 时,你的答案被接受。

输入输出样例

  • 输入#1

    3 3
    1 2 2
    2 3 2
    1 3 3
    5
    0
    1
    2
    3
    4

    输出#1

    3.0000000000
    4.0000000000
    4.5000000000
    5.0000000000
    5.5000000000

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

首页